From 6ea8a62bda376c713ae3fdb72ae1c881fea836fc Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 13 Dec 2022 22:02:15 +0000 Subject: [PATCH 1/2] feat: added sharding_config field in DocumentOutputConfig.GcsOutputConfig in document_io.proto PiperOrigin-RevId: 495051185 Source-Link: https://github.com/googleapis/googleapis/commit/0ff0b240ca1026d914e2256d4a32f885d1a31c54 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ffa8b5f51bd4258481b8fc73ca7370f78847d5d7 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbnRlbnR3YXJlaG91c2UvLk93bEJvdC55YW1sIiwiaCI6ImZmYThiNWY1MWJkNDI1ODQ4MWI4ZmM3M2NhNzM3MGY3ODg0N2Q1ZDcifQ== --- .../v1/.eslintignore | 7 + .../v1/.eslintrc.json | 3 + .../v1/.gitignore | 14 + .../v1/.jsdoc.js | 55 + .../v1/.mocharc.js | 33 + .../v1/.prettierrc.js | 22 + .../v1/README.md | 1 + .../v1/linkinator.config.json | 16 + .../v1/package.json | 68 + .../v1/async_document_service_request.proto | 35 + .../cloud/contentwarehouse/v1/common.proto | 140 ++ .../cloud/contentwarehouse/v1/document.proto | 310 ++++ .../v1/document_link_service.proto | 227 +++ .../contentwarehouse/v1/document_schema.proto | 166 ++ .../v1/document_schema_service.proto | 174 ++ .../v1/document_service.proto | 249 +++ .../v1/document_service_request.proto | 279 +++ .../cloud/contentwarehouse/v1/filters.proto | 206 +++ .../cloud/contentwarehouse/v1/histogram.proto | 102 ++ .../contentwarehouse/v1/rule_engine.proto | 276 +++ .../contentwarehouse/v1/ruleset_service.proto | 77 + .../v1/ruleset_service_request.proto | 118 ++ .../contentwarehouse/v1/synonymset.proto | 58 + .../v1/synonymset_service.proto | 83 + .../v1/synonymset_service_request.proto | 122 ++ .../google/cloud/documentai/v1/barcode.proto | 69 + .../google/cloud/documentai/v1/document.proto | 820 +++++++++ .../cloud/documentai/v1/document_io.proto | 103 ++ .../v1/document_processor_service.proto | 801 +++++++++ .../cloud/documentai/v1/document_schema.proto | 141 ++ .../google/cloud/documentai/v1/geometry.proto | 55 + .../documentai/v1/operation_metadata.proto | 66 + .../cloud/documentai/v1/processor.proto | 189 ++ .../cloud/documentai/v1/processor_type.proto | 63 + ...ument_link_service.create_document_link.js | 74 + ...ument_link_service.delete_document_link.js | 68 + ...cument_link_service.list_linked_sources.js | 84 + ...cument_link_service.list_linked_targets.js | 68 + ...t_schema_service.create_document_schema.js | 66 + ...t_schema_service.delete_document_schema.js | 61 + ...ment_schema_service.get_document_schema.js | 61 + ...nt_schema_service.list_document_schemas.js | 78 + ...t_schema_service.update_document_schema.js | 68 + .../v1/document_service.create_document.js | 89 + .../v1/document_service.delete_document.js | 70 + .../v1/document_service.fetch_acl.js | 74 + .../v1/document_service.get_document.js | 69 + .../v1/document_service.search_documents.js | 151 ++ .../generated/v1/document_service.set_acl.js | 80 + .../v1/document_service.update_document.js | 83 + .../v1/rule_set_service.create_rule_set.js | 67 + .../v1/rule_set_service.delete_rule_set.js | 63 + .../v1/rule_set_service.get_rule_set.js | 63 + .../v1/rule_set_service.list_rule_sets.js | 78 + .../v1/rule_set_service.update_rule_set.js | 68 + ...data.google.cloud.contentwarehouse.v1.json | 1231 +++++++++++++ .../synonym_set_service.create_synonym_set.js | 67 + .../synonym_set_service.delete_synonym_set.js | 63 + .../v1/synonym_set_service.get_synonym_set.js | 63 + .../synonym_set_service.list_synonym_sets.js | 78 + .../synonym_set_service.update_synonym_set.js | 68 + .../v1/src/index.ts | 33 + .../v1/src/v1/document_link_service_client.ts | 1095 ++++++++++++ .../document_link_service_client_config.json | 46 + .../v1/document_link_service_proto_list.json | 21 + .../src/v1/document_schema_service_client.ts | 1185 +++++++++++++ ...document_schema_service_client_config.json | 63 + .../document_schema_service_proto_list.json | 21 + .../v1/src/v1/document_service_client.ts | 1557 +++++++++++++++++ .../v1/document_service_client_config.json | 73 + .../src/v1/document_service_proto_list.json | 21 + .../v1/src/v1/gapic_metadata.json | 359 ++++ .../v1/src/v1/index.ts | 23 + .../v1/src/v1/rule_set_service_client.ts | 1144 ++++++++++++ .../v1/rule_set_service_client_config.json | 63 + .../src/v1/rule_set_service_proto_list.json | 21 + .../v1/src/v1/synonym_set_service_client.ts | 1150 ++++++++++++ .../v1/synonym_set_service_client_config.json | 63 + .../v1/synonym_set_service_proto_list.json | 21 + .../system-test/fixtures/sample/src/index.js | 31 + .../system-test/fixtures/sample/src/index.ts | 56 + .../v1/system-test/install.ts | 49 + .../v1/test/gapic_document_link_service_v1.ts | 1053 +++++++++++ .../test/gapic_document_schema_service_v1.ts | 1199 +++++++++++++ .../v1/test/gapic_document_service_v1.ts | 1377 +++++++++++++++ .../v1/test/gapic_rule_set_service_v1.ts | 1161 ++++++++++++ .../v1/test/gapic_synonym_set_service_v1.ts | 1161 ++++++++++++ .../v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + 89 files changed, 21430 insertions(+) create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/README.md create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/package.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/common.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_link_service.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema_service.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service_request.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/filters.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/histogram.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/rule_engine.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/barcode.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_io.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_processor_service.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_schema.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/geometry.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/operation_metadata.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor_type.proto create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.create_document_link.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.delete_document_link.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_sources.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_targets.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.create_document_schema.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.delete_document_schema.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.get_document_schema.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.list_document_schemas.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.update_document_schema.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.create_document.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.delete_document.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.fetch_acl.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.get_document.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.search_documents.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.set_acl.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.update_document.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.create_rule_set.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.delete_rule_set.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.get_rule_set.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.list_rule_sets.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.update_rule_set.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/snippet_metadata.google.cloud.contentwarehouse.v1.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.create_synonym_set.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.delete_synonym_set.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.get_synonym_set.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.list_synonym_sets.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.update_synonym_set.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_link_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_schema_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_rule_set_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_synonym_set_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintignore b/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintrc.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.gitignore b/owl-bot-staging/google-cloud-contentwarehouse/v1/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.jsdoc.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/.jsdoc.js new file mode 100644 index 00000000000..53260dc06f0 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/contentwarehouse', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.mocharc.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.prettierrc.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/README.md b/owl-bot-staging/google-cloud-contentwarehouse/v1/README.md new file mode 100644 index 00000000000..7315098501f --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/README.md @@ -0,0 +1 @@ +Contentwarehouse: Nodejs Client diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/linkinator.config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/package.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/package.json new file mode 100644 index 00000000000..e59c6bdc1c2 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/package.json @@ -0,0 +1,68 @@ +{ + "name": "@google-cloud/contentwarehouse", + "version": "0.1.0", + "description": "Contentwarehouse client for Node.js", + "repository": "googleapis/nodejs-contentwarehouse", + "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 contentwarehouse", + "contentwarehouse", + "document link service", + "document schema service", + "document service", + "rule set service", + "synonym set service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto new file mode 100644 index 00000000000..368ddf3f8cc --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto @@ -0,0 +1,35 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "AsyncDocumentServiceRequestProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// Metadata object for CreateDocument request (currently empty). +message CreateDocumentMetadata { + +} + +// Metadata object for UpdateDocument request (currently empty). +message UpdateDocumentMetadata { + +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/common.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/common.proto new file mode 100644 index 00000000000..9be7e86a34d --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/common.proto @@ -0,0 +1,140 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/resource.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; +option (google.api.resource_definition) = { + type: "contentwarehouse.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; + +// Meta information is used to improve the performance of the service. +message RequestMetadata { + // Provides user unique identification and groups information. + UserInfo user_info = 1; +} + +// Additional information returned to client, such as debugging information. +message ResponseMetadata { + // A unique id associated with this call. This id is logged for tracking + // purpose. + string request_id = 1; +} + +message UserInfo { + // A unique user identification string, as determined by the client. + // The maximum number of allowed characters is 255. + // Allowed characters include numbers 0 to 9, uppercase and lowercase letters, + // and restricted special symbols (:, @, +, -, _, ~) + // The format is "user:xxxx@example.com"; + string id = 1; + + // The unique group identifications which the user is belong to. + // The format is "group:yyyy@example.com"; + repeated string group_ids = 2; +} + +// Options for Update operations. +message UpdateOptions { + // Type for update. + UpdateType update_type = 1; + + // Field mask for merging Document fields. + // For the `FieldMask` definition, + // see + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + google.protobuf.FieldMask update_mask = 2; + + // Options for merging. + MergeFieldsOptions merge_fields_options = 3; +} + +// Options for merging updated fields. +message MergeFieldsOptions { + // When merging message fields, the default behavior is to merge + // the content of two message fields together. If you instead want to use + // the field from the source message to replace the corresponding field in + // the destination message, set this flag to true. When this flag is set, + // specified submessage fields that are missing in source will be cleared in + // destination. + optional bool replace_message_fields = 1; + + // When merging repeated fields, the default behavior is to append + // entries from the source repeated field to the destination repeated field. + // If you instead want to keep only the entries from the source repeated + // field, set this flag to true. + // + // If you want to replace a repeated field within a message field on the + // destination message, you must set both replace_repeated_fields and + // replace_message_fields to true, otherwise the repeated fields will be + // appended. + optional bool replace_repeated_fields = 2; +} + +// Update type of the requests. +enum UpdateType { + // Defaults to full replace behavior, ie. FULL_REPLACE. + UPDATE_TYPE_UNSPECIFIED = 0; + + // Fully replace all the fields. Any field masks will be ignored. + UPDATE_TYPE_REPLACE = 1; + + // Merge the fields into the existing entities. + UPDATE_TYPE_MERGE = 2; + + // Inserts the properties by names. + UPDATE_TYPE_INSERT_PROPERTIES_BY_NAMES = 3; + + // Replace the properties by names. + UPDATE_TYPE_REPLACE_PROPERTIES_BY_NAMES = 4; + + // Delete the properties by names. + UPDATE_TYPE_DELETE_PROPERTIES_BY_NAMES = 5; +} + +// Type of database used by the customer +enum DatabaseType { + // This value is required by protobuf best practices + DB_UNKNOWN = 0; + + // Internal Spanner + DB_INFRA_SPANNER = 1; + + // Cloud Sql with a Postgres Sql instance + DB_CLOUD_SQL_POSTGRES = 2; +} + +// Access Control Mode. +enum AccessControlMode { + // This value is required by protobuf best practices + ACL_MODE_UNKNOWN = 0; + + // Universal Access: No document level access control. + ACL_MODE_UNIVERSAL_ACCESS = 1; + + // Document level access control with customer own Identity Service. + ACL_MODE_DOCUMENT_LEVEL_ACCESS_CONTROL_BYOID = 2; + + // Document level access control using Google Cloud Identity. + ACL_MODE_DOCUMENT_LEVEL_ACCESS_CONTROL_GCI = 3; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document.proto new file mode 100644 index 00000000000..5ec6c2ec686 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document.proto @@ -0,0 +1,310 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/documentai/v1/document.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/datetime.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// Defines the structure for content warehouse document proto. +message Document { + option (google.api.resource) = { + type: "contentwarehouse.googleapis.com/Document" + pattern: "projects/{project}/locations/{location}/documents/{document}" + pattern: "projects/{project}/locations/{location}/documents/referenceId/{reference_id}" + }; + + // The resource name of the document. + // Format: + // projects/{project_number}/locations/{location}/documents/{document_id}. + // + // The name is ignored when creating a document. + string name = 1; + + // The reference ID set by customers. Must be unique per project and location. + string reference_id = 11; + + // Required. Display name of the document given by the user. This name will be displayed + // in the UI. + // Customer can populate this field with the name of the document. This + // differs from the 'title' field as 'title' is optional and stores the top + // heading in the document. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Title that describes the document. + // This is usually present in the top section of the document, and is a + // mandatory field for the question-answering feature. + string title = 18; + + // Uri to display the document, for example, in the UI. + string display_uri = 17; + + // The Document schema name. + // Format: + // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. + string document_schema_name = 3 [(google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/DocumentSchema" + }]; + + oneof structured_content { + // Other document format, such as PPTX, XLXS + string plain_text = 15; + + // Document AI format to save the structured content, including OCR. + google.cloud.documentai.v1.Document cloud_ai_document = 4; + } + + // A path linked to structured content file. + string structured_content_uri = 16; + + // Raw document file. + oneof raw_document { + // Raw document file in Cloud Storage path. + string raw_document_path = 5; + + // Raw document content. + bytes inline_raw_document = 6; + } + + // List of values that are user supplied metadata. + repeated Property properties = 7; + + // Output only. The time when the document is last updated. + google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the document is created. + google.protobuf.Timestamp create_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // This is used when DocAI was not used to load the document and parsing/ + // extracting is needed for the inline_raw_document. For example, if + // inline_raw_document is the byte representation of a PDF file, then + // this should be set to: RAW_DOCUMENT_FILE_TYPE_PDF. + RawDocumentFileType raw_document_file_type = 10; + + // If true, makes the document visible to asynchronous policies and rules. + bool async_enabled = 12; + + // If true, text extraction will not be performed. + bool text_extraction_disabled = 19; + + // The user who creates the document. + string creator = 13; + + // The user who lastly updates the document. + string updater = 14; +} + +// References to the documents. +message DocumentReference { + // Required. Name of the referenced document. + string document_name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Document" + } + ]; + + // display_name of the referenced document; this name does not need to be + // consistent to the display_name in the Document proto, depending on the ACL + // constraint. + string display_name = 2; + + // Stores the subset of the referenced document's content. + // This is useful to allow user peek the information of the referenced + // document. + string snippet = 3; + + // The document type of the document being referenced. + bool document_is_folder = 4; + + // Output only. The time when the document is last updated. + google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the document is created. + google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the document is deleted. + google.protobuf.Timestamp delete_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Property of a document. +message Property { + // Required. Must match the name of a PropertyDefinition in the DocumentSchema. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Type of the property. + // Must match the property_options type of the matching PropertyDefinition. + // Value of the Property parsed into a specific data type. + // Specific type value(s) obtained from Document AIs Property.mention_text + // field. + oneof values { + // Integer property values. + IntegerArray integer_values = 2; + + // Float property values. + FloatArray float_values = 3; + + // String/text property values. + TextArray text_values = 4; + + // Enum property values. + EnumArray enum_values = 5; + + // Nested structured data property values. + PropertyArray property_values = 6; + + // Date time property values. + // It is not supported by CMEK compliant deployment. + DateTimeArray date_time_values = 7; + + // Map property values. + MapProperty map_property = 8; + + // Timestamp property values. + // It is not supported by CMEK compliant deployment. + TimestampArray timestamp_values = 9; + } +} + +// Integer values. +message IntegerArray { + // List of integer values. + repeated int32 values = 1; +} + +// Float values. +message FloatArray { + // List of float values. + repeated float values = 1; +} + +// String/text values. +message TextArray { + // List of text values. + repeated string values = 1; +} + +// Enum values. +message EnumArray { + // List of enum values. + repeated string values = 1; +} + +// DateTime values. +message DateTimeArray { + // List of datetime values. + // Both OffsetDateTime and ZonedDateTime are supported. + repeated google.type.DateTime values = 1; +} + +// Timestamp values. +message TimestampArray { + // List of timestamp values. + repeated TimestampValue values = 1; +} + +// Timestamp value type. +message TimestampValue { + oneof value { + // Timestamp value + google.protobuf.Timestamp timestamp_value = 1; + + // The string must represent a valid instant in UTC and is parsed using + // java.time.format.DateTimeFormatter.ISO_INSTANT. + // e.g. "2013-09-29T18:46:19Z" + string text_value = 2; + } +} + +// Property values. +message PropertyArray { + // List of property values. + repeated Property properties = 1; +} + +// Map property value. +// Represents a structured entries of key value pairs, consisting of field names +// which map to dynamically typed values. +message MapProperty { + // Unordered map of dynamically typed values. + map fields = 1; +} + +// `Value` represents a dynamically typed value which can be either be +// a float, a integer, a string, or a datetime value. A producer of value is +// expected to set one of these variants. Absence of any variant indicates an +// error. +message Value { + // The kind of value. + oneof kind { + // Represents a float value. + float float_value = 1; + + // Represents a integer value. + int32 int_value = 2; + + // Represents a string value. + string string_value = 3; + + // Represents an enum value. + EnumValue enum_value = 4; + + // Represents a datetime value. + google.type.DateTime datetime_value = 5; + + // Represents a timestamp value. + TimestampValue timestamp_value = 6; + + // Represents a boolean value. + bool boolean_value = 7; + } +} + +// Represents the string value of the enum field. +message EnumValue { + // String value of the enum field. This must match defined set of enums + // in document schema using EnumTypeOptions. + string value = 1; +} + +// When a raw document is supplied, this indicates the file format +enum RawDocumentFileType { + // No raw document specified or it is non-parsable + RAW_DOCUMENT_FILE_TYPE_UNSPECIFIED = 0; + + // Adobe PDF format + RAW_DOCUMENT_FILE_TYPE_PDF = 1; + + // Microsoft Word format + RAW_DOCUMENT_FILE_TYPE_DOCX = 2; + + // Microsoft Excel format + RAW_DOCUMENT_FILE_TYPE_XLSX = 3; + + // Microsoft Powerpoint format + RAW_DOCUMENT_FILE_TYPE_PPTX = 4; + + // UTF-8 encoded text format + RAW_DOCUMENT_FILE_TYPE_TEXT = 5; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_link_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_link_service.proto new file mode 100644 index 00000000000..a5a14d8dcbf --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_link_service.proto @@ -0,0 +1,227 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/contentwarehouse/v1/common.proto"; +import "google/cloud/contentwarehouse/v1/document.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "DocumentLinkServiceProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// This service lets you manage document-links. +// Document-Links are treated as sub-resources under source documents. +service DocumentLinkService { + option (google.api.default_host) = "contentwarehouse.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Return all target document-links from the document. + rpc ListLinkedTargets(ListLinkedTargetsRequest) returns (ListLinkedTargetsResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/documents/*}/linkedTargets" + body: "*" + }; + option (google.api.method_signature) = "parent"; + } + + // Return all source document-links from the document. + rpc ListLinkedSources(ListLinkedSourcesRequest) returns (ListLinkedSourcesResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/documents/*}/linkedSources" + body: "*" + }; + option (google.api.method_signature) = "parent"; + } + + // Create a link between a source document and a target document. + rpc CreateDocumentLink(CreateDocumentLinkRequest) returns (DocumentLink) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/documents/*}/documentLinks" + body: "*" + }; + option (google.api.method_signature) = "parent,document_link"; + } + + // Remove the link between the source and target documents. + rpc DeleteDocumentLink(DeleteDocumentLinkRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/documents/*/documentLinks/*}:delete" + body: "*" + }; + option (google.api.method_signature) = "name"; + } +} + +// Response message for DocumentLinkService.ListLinkedTargets. +message ListLinkedTargetsResponse { + // Target document-links. + repeated DocumentLink document_links = 1; + + // A token, which can be sent as `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 DocumentLinkService.ListLinkedTargets. +message ListLinkedTargetsRequest { + // Required. The name of the document, for which all target links are returned. + // Format: + // projects/{project_number}/locations/{location}/documents/{target_document_id}. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Document" + } + ]; + + // The meta information collected about the document creator, used to enforce + // access control for the service. + RequestMetadata request_metadata = 2; +} + +// Response message for DocumentLinkService.ListLinkedSources. +message ListLinkedSourcesResponse { + // Source document-links. + repeated DocumentLink document_links = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Response message for DocumentLinkService.ListLinkedSources. +message ListLinkedSourcesRequest { + // Required. The name of the document, for which all source links are returned. + // Format: + // projects/{project_number}/locations/{location}/documents/{source_document_id}. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Document" + } + ]; + + // The maximum number of document-links to return. The service may return + // fewer than this value. + // + // If unspecified, at most 50 document-links will be returned. + // The maximum value is 1000; values above 1000 will be coerced to 1000. + int32 page_size = 3; + + // A page token, received from a previous `ListLinkedSources` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListLinkedSources` + // must match the call that provided the page token. + string page_token = 4; + + // The meta information collected about the document creator, used to enforce + // access control for the service. + RequestMetadata request_metadata = 2; +} + +// A document-link between source and target document. +message DocumentLink { + option (google.api.resource) = { + type: "contentwarehouse.googleapis.com/DocumentLink" + pattern: "projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}" + }; + + // The state of a document-link. + enum State { + // Unknown state of documentlink. + STATE_UNSPECIFIED = 0; + + // The documentlink has both source and target documents detected. + ACTIVE = 1; + + // Target document is deleted, and mark the documentlink as soft-deleted. + SOFT_DELETED = 2; + } + + // Name of this document-link. + // It is required that the parent derived form the name to be consistent with + // the source document reference. Otherwise an exception will be thrown. + // Format: + // projects/{project_number}/locations/{location}/documents/{source_document_id}/documentLinks/{document_link_id}. + string name = 1; + + // Document references of the source document. + DocumentReference source_document_reference = 2; + + // Document references of the target document. + DocumentReference target_document_reference = 3; + + // Description of this document-link. + string description = 4; + + // Output only. The time when the documentLink is last updated. + google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the documentLink is created. + google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The state of the documentlink. If target node has been deleted, the + // link is marked as invalid. Removing a source node will result in removal + // of all associated links. + State state = 7; +} + +// Request message for DocumentLinkService.CreateDocumentLink. +message CreateDocumentLinkRequest { + // Required. Parent of the document-link to be created. + // parent of document-link should be a document. + // Format: + // projects/{project_number}/locations/{location}/documents/{source_document_id}. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Document" + } + ]; + + // Required. Document links associated with the source documents (source_document_id). + DocumentLink document_link = 2 [(google.api.field_behavior) = REQUIRED]; + + // The meta information collected about the document creator, used to enforce + // access control for the service. + RequestMetadata request_metadata = 3; +} + +// Request message for DocumentLinkService.DeleteDocumentLink. +message DeleteDocumentLinkRequest { + // Required. The name of the document-link to be deleted. + // Format: + // projects/{project_number}/locations/{location}/documents/{source_document_id}/documentLinks/{document_link_id}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/DocumentLink" + } + ]; + + // The meta information collected about the document creator, used to enforce + // access control for the service. + RequestMetadata request_metadata = 2; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema.proto new file mode 100644 index 00000000000..fae52e4c51e --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema.proto @@ -0,0 +1,166 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "DocumentSchemaProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// A document schema used to define document structure. +message DocumentSchema { + option (google.api.resource) = { + type: "contentwarehouse.googleapis.com/DocumentSchema" + pattern: "projects/{project}/locations/{location}/documentSchemas/{document_schema}" + }; + + // The resource name of the document schema. + // Format: + // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. + // + // The name is ignored when creating a document schema. + string name = 1; + + // Required. Name of the schema given by the user. Must be unique per customer. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Document details. + repeated PropertyDefinition property_definitions = 3; + + // Document Type, true refers the document is a folder, otherwise it is + // a typical document. + bool document_is_folder = 4; + + // Output only. The time when the document schema is last updated. + google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the document schema is created. + google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Schema description. + string description = 7; +} + +// Defines the metadata for a schema property. +message PropertyDefinition { + // Required. The name of the metadata property. + // Must be unique within a document schema and is case insensitive. + // Names must be non-blank, start with a letter, and can contain alphanumeric + // characters and: /, :, -, _, and . + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The display-name for the property, used for front-end. + string display_name = 12; + + // Whether the property can have multiple values. + bool is_repeatable = 2; + + // Whether the property can be filtered. If this is a sub-property, all the + // parent properties must be marked filterable. + bool is_filterable = 3; + + // Indicates that the property should be included in a global search. + bool is_searchable = 4; + + // Whether the property is user supplied metadata. + bool is_metadata = 5; + + // Whether the property is mandatory. + // Default is 'false', i.e. populating property value can be skipped. + // If 'true' then user must populate the value for this property. + bool is_required = 14; + + // Type of the property. + oneof value_type_options { + // Integer property. + IntegerTypeOptions integer_type_options = 7; + + // Float property. + FloatTypeOptions float_type_options = 8; + + // Text/string property. + TextTypeOptions text_type_options = 9; + + // Nested structured data property. + PropertyTypeOptions property_type_options = 10; + + // Enum/categorical property. + EnumTypeOptions enum_type_options = 11; + + // Date time property. + // It is not supported by CMEK compliant deployment. + DateTimeTypeOptions date_time_type_options = 13; + + // Map property. + MapTypeOptions map_type_options = 15; + + // Timestamp property. + // It is not supported by CMEK compliant deployment. + TimestampTypeOptions timestamp_type_options = 16; + } +} + +// Configurations for an integer property. +message IntegerTypeOptions { + +} + +// Configurations for a float property. +message FloatTypeOptions { + +} + +// Configurations for a text property. +message TextTypeOptions { + +} + +// Configurations for a date time property. +message DateTimeTypeOptions { + +} + +// Configurations for a Map property. +message MapTypeOptions { + +} + +// Configurations for a timestamp property. +message TimestampTypeOptions { + +} + +// Configurations for a nested structured data property. +message PropertyTypeOptions { + // Required. List of property definitions. + repeated PropertyDefinition property_definitions = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Configurations for an enum/categorical property. +message EnumTypeOptions { + // Required. List of possible enum values. + repeated string possible_values = 1 [(google.api.field_behavior) = REQUIRED]; + + // Make sure the Enum property value provided in the document is in the + // possile value list during document creation. The validation check runs by + // default. + bool validation_check_disabled = 2; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema_service.proto new file mode 100644 index 00000000000..9c570695045 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema_service.proto @@ -0,0 +1,174 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/contentwarehouse/v1/document_schema.proto"; +import "google/protobuf/empty.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "DocumentSchemaServiceProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// (go/id-aip-list) to add a finite deadline and enable fail_fast. + +// This service lets you manage document schema. +service DocumentSchemaService { + option (google.api.default_host) = "contentwarehouse.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a document schema. + rpc CreateDocumentSchema(CreateDocumentSchemaRequest) returns (DocumentSchema) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/documentSchemas" + body: "document_schema" + }; + option (google.api.method_signature) = "parent,document_schema"; + } + + // Updates a Document Schema. Returns INVALID_ARGUMENT if the name of the + // Document Schema is non-empty and does not equal the existing name. + // Supports only appending new properties, adding new ENUM possible values, + // and updating the [EnumTypeOptions.validation_check_disabled][google.cloud.contentwarehouse.v1.EnumTypeOptions.validation_check_disabled] flag for + // ENUM possible values. Updating existing properties will result into + // INVALID_ARGUMENT. + rpc UpdateDocumentSchema(UpdateDocumentSchemaRequest) returns (DocumentSchema) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/documentSchemas/*}" + body: "*" + }; + option (google.api.method_signature) = "name,document_schema"; + } + + // Gets a document schema. Returns NOT_FOUND if the document schema does not + // exist. + rpc GetDocumentSchema(GetDocumentSchemaRequest) returns (DocumentSchema) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/documentSchemas/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes a document schema. Returns NOT_FOUND if the document schema does + // not exist. Returns BAD_REQUEST if the document schema has documents + // depending on it. + rpc DeleteDocumentSchema(DeleteDocumentSchemaRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/documentSchemas/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists document schemas. + rpc ListDocumentSchemas(ListDocumentSchemasRequest) returns (ListDocumentSchemasResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/documentSchemas" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request message for DocumentSchemaService.CreateDocumentSchema. +message CreateDocumentSchemaRequest { + // Required. The parent name. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Location" + } + ]; + + // Required. The document schema to create. + DocumentSchema document_schema = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for DocumentSchemaService.GetDocumentSchema. +message GetDocumentSchemaRequest { + // Required. The name of the document schema to retrieve. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/DocumentSchema" + } + ]; +} + +// Request message for DocumentSchemaService.UpdateDocumentSchema. +message UpdateDocumentSchemaRequest { + // Required. The name of the document schema to update. + // Format: + // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/DocumentSchema" + } + ]; + + // Required. The document schema to update with. + DocumentSchema document_schema = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for DocumentSchemaService.DeleteDocumentSchema. +message DeleteDocumentSchemaRequest { + // Required. The name of the document schema to delete. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/DocumentSchema" + } + ]; +} + +// Request message for DocumentSchemaService.ListDocumentSchemas. +message ListDocumentSchemasRequest { + // Required. The parent, which owns this collection of document schemas. + // Format: projects/{project_number}/locations/{location}. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Location" + } + ]; + + // The maximum number of document schemas to return. The service may return + // fewer than this value. + // If unspecified, at most 50 document schemas will be returned. + // The maximum value is 1000; values above 1000 will be coerced to 1000. + int32 page_size = 2; + + // A page token, received from a previous `ListDocumentSchemas` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListDocumentSchemas` + // must match the call that provided the page token. + string page_token = 3; +} + +// Response message for DocumentSchemaService.ListDocumentSchemas. +message ListDocumentSchemasResponse { + // The document schemas from the specified parent. + repeated DocumentSchema document_schemas = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service.proto new file mode 100644 index 00000000000..e0c1c875088 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service.proto @@ -0,0 +1,249 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/resource.proto"; +import "google/cloud/contentwarehouse/v1/common.proto"; +import "google/cloud/contentwarehouse/v1/document.proto"; +import "google/cloud/contentwarehouse/v1/document_service_request.proto"; +import "google/cloud/contentwarehouse/v1/histogram.proto"; +import "google/cloud/contentwarehouse/v1/rule_engine.proto"; +import "google/iam/v1/policy.proto"; +import "google/protobuf/empty.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "DocumentServiceProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// This service lets you manage document. +service DocumentService { + option (google.api.default_host) = "contentwarehouse.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a document. + rpc CreateDocument(CreateDocumentRequest) returns (CreateDocumentResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/documents" + body: "*" + }; + option (google.api.method_signature) = "parent,document"; + } + + // Gets a document. Returns NOT_FOUND if the document does not exist. + rpc GetDocument(GetDocumentRequest) returns (Document) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/documents/*}:get" + body: "*" + additional_bindings { + post: "/v1/{name=projects/*/locations/*/documents/referenceId/*}:get" + body: "*" + } + }; + option (google.api.method_signature) = "name"; + } + + // Updates a document. Returns INVALID_ARGUMENT if the name of the document + // is non-empty and does not equal the existing name. + rpc UpdateDocument(UpdateDocumentRequest) returns (UpdateDocumentResponse) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/documents/*}" + body: "*" + additional_bindings { + patch: "/v1/{name=projects/*/locations/*/documents/referenceId/*}" + body: "*" + } + }; + option (google.api.method_signature) = "name,document"; + } + + // Deletes a document. Returns NOT_FOUND if the document does not exist. + rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/documents/*}:delete" + body: "*" + additional_bindings { + post: "/v1/{name=projects/*/locations/*/documents/referenceId/*}:delete" + body: "*" + } + }; + option (google.api.method_signature) = "name"; + } + + // Searches for documents using provided [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. + // This call only returns documents that the caller has permission to search + // against. + rpc SearchDocuments(SearchDocumentsRequest) returns (SearchDocumentsResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/documents:search" + body: "*" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the access control policy for a resource. Returns NOT_FOUND error if + // the resource does not exist. Returns an empty policy if the resource exists + // but does not have a policy set. + rpc FetchAcl(FetchAclRequest) returns (FetchAclResponse) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/locations/*/documents/*}:fetchAcl" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*}:fetchAcl" + body: "*" + } + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy for a resource. Replaces any existing + // policy. + rpc SetAcl(SetAclRequest) returns (SetAclResponse) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/locations/*/documents/*}:setAcl" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*}:setAcl" + body: "*" + } + }; + option (google.api.method_signature) = "resource,policy"; + } +} + +// Response message for DocumentService.CreateDocument. +message CreateDocumentResponse { + // Document created after executing create request. + Document document = 1; + + // Output from Rule Engine recording the rule evaluator and action executor's + // output. + // + // Refer format in: google/cloud/contentwarehouse/v1/rule_engine.proto + RuleEngineOutput rule_engine_output = 2; + + // Additional information for the API invocation, such as the request tracking + // id. + ResponseMetadata metadata = 3; +} + +// Response message for DocumentService.UpdateDocument. +message UpdateDocumentResponse { + // Updated document after executing update request. + Document document = 1; + + // Output from Rule Engine recording the rule evaluator and action executor's + // output. + // + // Refer format in: google/cloud/contentwarehouse/v1/rule_engine.proto + RuleEngineOutput rule_engine_output = 2; + + // Additional information for the API invocation, such as the request tracking + // id. + ResponseMetadata metadata = 3; +} + +// Additional result info for the question-answering feature. +message QAResult { + // A text span in the search text snippet that represents a highlighted + // section (answer context, highly relevant sentence, etc.). + message Highlight { + // Start index of the highlight. + int32 start_index = 1; + + // End index of the highlight, exclusive. + int32 end_index = 2; + } + + // Highlighted sections in the snippet. + repeated Highlight highlights = 1; + + // The calibrated confidence score for this document, in the range + // [0., 1.]. This represents the confidence level for whether the returned + // document and snippet answers the user's query. + float confidence_score = 2; +} + +// Response message for DocumentService.SearchDocuments. +message SearchDocumentsResponse { + // Document entry with metadata inside [SearchDocumentsResponse][google.cloud.contentwarehouse.v1.SearchDocumentsResponse] + message MatchingDocument { + // Document that matches the specified [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. + // This document only contains indexed metadata information. + Document document = 1; + + // Contains snippets of text from the document full raw text that most + // closely match a search query's keywords, if available. All HTML tags in + // the original fields are stripped when returned in this field, and + // matching query keywords are enclosed in HTML bold tags. + // + // If the question-answering feature is enabled, this field will instead + // contain a snippet that answers the user's natural-language query. No HTML + // bold tags will be present, and highlights in the answer snippet can be + // found in [QAResult.highlights][google.cloud.contentwarehouse.v1.QAResult.highlights]. + string search_text_snippet = 2; + + // Experimental. + // Additional result info if the question-answering feature is enabled. + QAResult qa_result = 3; + } + + // The document entities that match the specified [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. + repeated MatchingDocument matching_documents = 1; + + // The token that specifies the starting position of the next page of results. + // This field is empty if there are no more results. + string next_page_token = 2; + + // The total number of matched documents which is available only if the client + // set [SearchDocumentsRequest.require_total_size][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.require_total_size] to `true`. Otherwise, the + // value will be `-1`. `total_size` will max at "100,000". If this + // is returned, then it can be assumed that the count is equal to or greater + // than 100,000. Typically a UI would handle this condition by displaying + // "of many", for example: "Displaying 10 of many". + int32 total_size = 3; + + // Additional information for the API invocation, such as the request tracking + // id. + ResponseMetadata metadata = 4; + + // The histogram results that match with the specified + // [SearchDocumentsRequest.histogram_queries][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.histogram_queries]. + repeated HistogramQueryResult histogram_query_results = 6; +} + +// Response message for DocumentService.FetchAcl. +message FetchAclResponse { + // The IAM policy. + google.iam.v1.Policy policy = 1; + + // Additional information for the API invocation, such as the request tracking + // id. + ResponseMetadata metadata = 2; +} + +// Response message for DocumentService.SetAcl. +message SetAclResponse { + // The policy will be attached to a resource (e.g. projecct, document). + google.iam.v1.Policy policy = 1; + + // Additional information for the API invocation, such as the request tracking + // id. + ResponseMetadata metadata = 2; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service_request.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service_request.proto new file mode 100644 index 00000000000..635bfdb6558 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service_request.proto @@ -0,0 +1,279 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/contentwarehouse/v1/common.proto"; +import "google/cloud/contentwarehouse/v1/document.proto"; +import "google/cloud/contentwarehouse/v1/filters.proto"; +import "google/cloud/contentwarehouse/v1/histogram.proto"; +import "google/iam/v1/policy.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "DocumentServiceRequestProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// Request Option for processing Cloud AI Document in CW Document. +message CloudAIDocumentOption { + // Whether to convert all the entities to properties. + bool enable_entities_conversions = 1; + + // If set, only selected entities will be converted to properties. + map customized_entities_properties_conversions = 2; +} + +// Request message for DocumentService.CreateDocument. +message CreateDocumentRequest { + // Required. The parent name. + // Format: projects/{project_number}/locations/{location}. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Location" + } + ]; + + // Required. The document to create. + Document document = 2 [(google.api.field_behavior) = REQUIRED]; + + // The meta information collected about the end user, used to enforce access + // control for the service. + RequestMetadata request_metadata = 3; + + // Default document policy during creation. Conditions defined in the policy + // will be ignored. + google.iam.v1.Policy policy = 4; + + // Request Option for processing Cloud AI Document in CW Document. + CloudAIDocumentOption cloud_ai_document_option = 5; + + // Field mask for creating Document fields. If mask path is empty, + // it means all fields are masked. + // For the `FieldMask` definition, + // see + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + google.protobuf.FieldMask create_mask = 6; +} + +// Request message for DocumentService.GetDocument. +message GetDocumentRequest { + // Required. The name of the document to retrieve. + // Format: + // projects/{project_number}/locations/{location}/documents/{document_id} or + // projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Document" + } + ]; + + // The meta information collected about the end user, used to enforce access + // control for the service. + RequestMetadata request_metadata = 2; +} + +// Request message for DocumentService.UpdateDocument. +message UpdateDocumentRequest { + // Required. The name of the document to update. + // Format: + // projects/{project_number}/locations/{location}/documents/{document_id} + // or + // projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Document" + } + ]; + + // Required. The document to update. + Document document = 2 [(google.api.field_behavior) = REQUIRED]; + + // The meta information collected about the end user, used to enforce access + // control for the service. + RequestMetadata request_metadata = 3; + + // Request Option for processing Cloud AI Document in CW Document. + CloudAIDocumentOption cloud_ai_document_option = 5; + + // Options for the update operation. + UpdateOptions update_options = 6; +} + +// Request message for DocumentService.DeleteDocument. +message DeleteDocumentRequest { + // Required. The name of the document to delete. + // Format: + // projects/{project_number}/locations/{location}/documents/{document_id} + // or + // projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Document" + } + ]; + + // The meta information collected about the end user, used to enforce access + // control for the service. + RequestMetadata request_metadata = 2; +} + +// Request message for DocumentService.SearchDocuments. +message SearchDocumentsRequest { + // Required. The parent, which owns this collection of documents. + // Format: projects/{project_number}/locations/{location}. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Location" + } + ]; + + // The meta information collected about the end user, used to enforce access + // control and improve the search quality of the service. + RequestMetadata request_metadata = 3; + + // Query used to search against documents (keyword, filters, etc.). + DocumentQuery document_query = 4; + + // An integer that specifies the current offset (that is, starting result + // location, amongst the documents deemed by the API as relevant) in search + // results. This field is only considered if [page_token][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.page_token] is unset. + // + // The maximum allowed value is 5000. Otherwise an error is thrown. + // + // For example, 0 means to return results starting from the first matching + // document, and 10 means to return from the 11th document. This can be used + // for pagination, (for example, pageSize = 10 and offset = 10 means to return + // from the second page). + int32 offset = 5; + + // A limit on the number of documents returned in the search results. + // Increasing this value above the default value of 10 can increase search + // response time. The value can be between 1 and 100. + int32 page_size = 6; + + // The token specifying the current offset within search results. + // See [SearchDocumentsResponse.next_page_token][google.cloud.contentwarehouse.v1.SearchDocumentsResponse.next_page_token] for an explanation of how + // to obtain the next set of query results. + string page_token = 7; + + // The criteria determining how search results are sorted. For non-empty + // query, default is `"relevance desc"`. For empty query, default is + // `"upload_date desc"`. + // + // Supported options are: + // + // * `"relevance desc"`: By relevance descending, as determined by the API + // algorithms. + // * `"upload_date desc"`: By upload date descending. + // * `"upload_date"`: By upload date ascending. + // * `"update_date desc"`: By last updated date descending. + // * `"update_date"`: By last updated date ascending. + string order_by = 8; + + // An expression specifying a histogram request against matching + // documents. Expression syntax is an aggregation function call with + // histogram facets and other options. + // + // The following aggregation functions are supported: + // + // * `count(string_histogram_facet)`: Count the number of matching entities + // for each distinct attribute value. + // + // Data types: + // + // * Histogram facet (aka filterable properties): Facet names with format + // <schema id>.<facet>. Facets will have the + // format of: `[a-zA-Z][a-zA-Z0-9_:/-.]`. If the facet is a child + // facet, then the parent hierarchy needs to be specified separated by + // dots in the prefix after the schema id. Thus, the format for a multi- + // level facet is: <schema id>.<parent facet name>. + // <child facet name>. Example: + // schema123.root_parent_facet.middle_facet.child_facet + // * DocumentSchemaId: (with no schema id prefix) to get + // histograms for each document type (returns the schema id path, e.g. + // projects/12345/locations/us-west/documentSchemas/abc123). + // + // Example expression: + // + // * Document type counts: + // count('DocumentSchemaId') + // + // * For schema id, abc123, get the counts for MORTGAGE_TYPE: + // count('abc123.MORTGAGE_TYPE') + repeated HistogramQuery histogram_queries = 9; + + // Optional. Controls if the search document request requires the return of a total size + // of matched documents. See [SearchDocumentsResponse.total_size][google.cloud.contentwarehouse.v1.SearchDocumentsResponse.total_size]. + // + // Enabling this flag may adversely impact performance. Hint: If this is + // used with pagination, set this flag on the initial query but set this + // to false on subsequent page calls (keep the total count locally). + // + // Defaults to false. + bool require_total_size = 10; + + // Experimental, do not use. + // The limit on the number of documents returned for the question-answering + // feature. To enable the question-answering feature, set + // [DocumentQuery].[is_nl_query][] to true. + int32 qa_size_limit = 11; +} + +// Request message for DocumentService.FetchAcl +message FetchAclRequest { + // Required. REQUIRED: The resource for which the policy is being requested. + // Format for document: + // projects/{project_number}/locations/{location}/documents/{document_id}. + // Format for project: projects/{project_number}. + string resource = 1 [(google.api.field_behavior) = REQUIRED]; + + // The meta information collected about the end user, used to enforce access + // control for the service. + RequestMetadata request_metadata = 2; + + // For Get Project ACL only. Authorization check for end user will be ignored + // when project_owner=true. + bool project_owner = 3; +} + +// Request message for DocumentService.SetAcl. +message SetAclRequest { + // Required. REQUIRED: The resource for which the policy is being requested. + // Format for document: + // projects/{project_number}/locations/{location}/documents/{document_id}. + // Format for project: projects/{project_number}. + string resource = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. REQUIRED: The complete policy to be applied to the `resource`. The size of + // the policy is limited to a few 10s of KB. + google.iam.v1.Policy policy = 2 [(google.api.field_behavior) = REQUIRED]; + + // The meta information collected about the end user, used to enforce access + // control for the service. + RequestMetadata request_metadata = 3; + + // For Set Project ACL only. Authorization check for end user will be ignored + // when project_owner=true. + bool project_owner = 4; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/filters.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/filters.proto new file mode 100644 index 00000000000..52e39ca90a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/filters.proto @@ -0,0 +1,206 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/resource.proto"; +import "google/type/interval.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "FiltersProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +message DocumentQuery { + // The query string that matches against the full text of the document and + // the searchable properties. + // The maximum number of allowed characters is 255. + string query = 1; + + // Experimental, do not use. + // If the query is a natural language question. False by default. If true, + // then the question-answering feature will be used instead of search, and + // `result_count` in [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest] must be set. In addition, all + // other input fields related to search (pagination, histograms, etc.) will be + // ignored. + bool is_nl_query = 12; + + // This filter specifies a structured syntax to match against the + // [PropertyDefinition].[is_filterable][] marked as `true`. The syntax for + // this expression is a subset of SQL syntax. + // + // Supported operators are: `=`, `!=`, `<`, `<=`, `>`, and `>=` where the left + // of the operator is a property name and the right of the operator is a + // number or a quoted string. You must escape backslash (\\) and quote (\") + // characters. Supported functions are `LOWER([property_name])` to perform a + // case insensitive match and `EMPTY([property_name])` to filter on the + // existence of a key. + // + // Boolean expressions (AND/OR/NOT) are supported up to 3 levels of nesting + // (for example, "((A AND B AND C) OR NOT D) AND E"), a maximum of 100 + // comparisons or functions are allowed in the expression. The expression must + // be < 6000 bytes in length. + // + // Sample Query: + // `(LOWER(driving_license)="class \"a\"" OR EMPTY(driving_license)) AND + // driving_years > 10` + string custom_property_filter = 4 [deprecated = true]; + + // Documents created/updated within a range specified by this filter are + // searched against. + repeated TimeFilter time_filters = 5; + + // This filter specifies the exact document schema + // [Document.document_schema_name][google.cloud.contentwarehouse.v1.Document.document_schema_name] of the documents to search against. + // + // If a value isn't specified, documents within the search results are + // associated with any schema. If multiple values are specified, documents + // within the search results may be associated with any of the specified + // schemas. + // + // At most 20 document schema names are allowed. + repeated string document_schema_names = 6; + + // This filter specifies a structured syntax to match against the + // [PropertyDefinition.is_filterable][google.cloud.contentwarehouse.v1.PropertyDefinition.is_filterable] marked as `true`. The relationship + // between the PropertyFilters is OR. + repeated PropertyFilter property_filter = 7; + + // This filter specifies the types of files to return: ALL, FOLDER, or FILE. + // If FOLDER or FILE is specified, then only either folders or files will be + // returned, respectively. If ALL is specified, both folders and files will be + // returned. + // + // If no value is specified, ALL files will be returned. + FileTypeFilter file_type_filter = 8; + + // Search all the documents under this specified folder. + // Format: + // projects/{project_number}/locations/{location}/documents/{document_id}. + string folder_name_filter = 9; + + // For custom synonyms. + // Customers provide the synonyms based on context. One customer can provide + // multiple set of synonyms based on different context. The search query will + // be expanded based on the custom synonyms of the query context set. + // By default, no custom synonyms wll be applied if no query context is + // provided. + // It is not supported for CMEK compliant deployment. + repeated string query_context = 10; + + // The exact creator(s) of the documents to search against. + // + // If a value isn't specified, documents within the search results are + // associated with any creator. If multiple values are specified, documents + // within the search results may be associated with any of the specified + // creators. + repeated string document_creator_filter = 11; +} + +// Filter on create timestamp or update timestamp of documents. +message TimeFilter { + // Time field used in TimeFilter. + enum TimeField { + // Default value. + TIME_FIELD_UNSPECIFIED = 0; + + // Earliest document create time. + CREATE_TIME = 1; + + // Latest document update time. + UPDATE_TIME = 2; + } + + google.type.Interval time_range = 1; + + // Specifies which time field to filter documents on. + // + // Defaults to [TimeField.UPLOAD_TIME][]. + TimeField time_field = 2; +} + +message PropertyFilter { + // The Document schema name [Document.document_schema_name][google.cloud.contentwarehouse.v1.Document.document_schema_name]. + // Format: + // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. + string document_schema_name = 1 [(google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/DocumentSchema" + }]; + + // The filter condition. + // The syntax for this expression is a subset of SQL syntax. + // + // Supported operators are: `=`, `!=`, `<`, `<=`, `>`, `>=`, and `~~` where + // the left of the operator is a property name and the right of the operator + // is a number or a quoted string. You must escape backslash (\\) and quote + // (\") characters. + // + // `~~` is the LIKE operator. The right of the operator must be a string. The + // only supported property data type for LIKE is text_values. It provides + // semantic search functionality by parsing, stemming and doing synonyms + // expansion against the input query. It matches if the property contains + // semantic similar content to the query. It is not regex matching or wildcard + // matching. For example, "property.company ~~ \"google\"" will match records + // whose property `property.compnay` have values like "Google Inc.", "Google + // LLC" or "Google Company". + // + // Supported functions are `LOWER([property_name])` to perform a + // case insensitive match and `EMPTY([property_name])` to filter on the + // existence of a key. + // + // Boolean expressions (AND/OR/NOT) are supported up to 3 levels of nesting + // (for example, "((A AND B AND C) OR NOT D) AND E"), a maximum of 100 + // comparisons or functions are allowed in the expression. The expression must + // be < 6000 bytes in length. + // + // Only properties that are marked filterable are allowed + // ([PropertyDefinition.is_filterable][google.cloud.contentwarehouse.v1.PropertyDefinition.is_filterable]). Property names do not need to be + // prefixed by the document schema id (as is the case with histograms), + // however property names will need to be prefixed by its parent hierarchy, if + // any. For example: top_property_name.sub_property_name. + // + // Sample Query: + // `(LOWER(driving_license)="class \"a\"" OR EMPTY(driving_license)) AND + // driving_years > 10` + // + // + // CMEK compliant deployment only supports: + // + // * Operators: `=`, `<`, `<=`, `>`, and `>=`. + // * Boolean expressions: AND and OR. + string condition = 2; +} + +// Filter for the specific types of documents returned. +message FileTypeFilter { + // Representation of the types of files. + enum FileType { + // Default document type. If set, disables the filter. + FILE_TYPE_UNSPECIFIED = 0; + + // Returns all document types, including folders. + ALL = 1; + + // Returns only folders. + FOLDER = 2; + + // Returns only non-folder documents. + DOCUMENT = 3; + } + + // The type of files to return. + FileType file_type = 1; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/histogram.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/histogram.proto new file mode 100644 index 00000000000..ce25e7a8c3f --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/histogram.proto @@ -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 +// +// 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.contentwarehouse.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "HistogramProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// The histogram request. +message HistogramQuery { + // An expression specifies a histogram request against matching documents for + // searches. + // + // See [SearchDocumentsRequest.histogram_queries][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.histogram_queries] for details about syntax. + string histogram_query = 1; + + // Controls if the histogram query requires the return of a precise count. + // Enable this flag may adversely impact performance. + // + // Defaults to true. + bool require_precise_result_size = 2; + + // Optional. Filter the result of histogram query by the property names. It only works + // with histogram query count('FilterableProperties'). + // It is an optional. It will perform histogram on all the property names for + // all the document schemas. Setting this field will have a better + // performance. + HistogramQueryPropertyNameFilter filters = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +message HistogramQueryPropertyNameFilter { + // The result of the histogram query count('FilterableProperties') using + // HISTOGRAM_YAXIS_DOCUMENT will be: + // invoice_id: 2 + // address: 1 + // payment_method: 2 + // line_item_description: 1 + enum HistogramYAxis { + // Count the documents per property name. + HISTOGRAM_YAXIS_DOCUMENT = 0; + + // Count the properties per property name. + HISTOGRAM_YAXIS_PROPERTY = 1; + } + + // This filter specifies the exact document schema(s) + // [Document.document_schema_name][google.cloud.contentwarehouse.v1.Document.document_schema_name] to run histogram query against. + // It is optional. It will perform histogram for property names for all the + // document schemas if it is not set. + // + // At most 10 document schema names are allowed. + // Format: + // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. + repeated string document_schemas = 1 [(google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/DocumentSchema" + }]; + + // It is optional. It will perform histogram for all the property names if it + // is not set. + // The properties need to be defined with the is_filterable flag set to + // true and the name of the property should be in the format: + // "schemaId.propertyName". The property needs to be defined in the schema. + // Example: the schema id is abc. Then the name of property for property + // MORTGAGE_TYPE will be "abc.MORTGAGE_TYPE". + repeated string property_names = 2; + + // By default, the y_axis is HISTOGRAM_YAXIS_DOCUMENT if this field is not + // set. + HistogramYAxis y_axis = 3; +} + +// Histogram result that matches [HistogramQuery][google.cloud.contentwarehouse.v1.HistogramQuery] specified in searches. +message HistogramQueryResult { + // Requested histogram expression. + string histogram_query = 1; + + // A map from the values of the facet associated with distinct values to the + // number of matching entries with corresponding value. + // + // The key format is: + // + // * (for string histogram) string values stored in the field. + map histogram = 2; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/rule_engine.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/rule_engine.proto new file mode 100644 index 00000000000..7badc7b788a --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/rule_engine.proto @@ -0,0 +1,276 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/policy.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "RuleEngineProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// Represents a set of rules from a single customer. +message RuleSet { + option (google.api.resource) = { + type: "contentwarehouse.googleapis.com/RuleSet" + pattern: "projects/{project}/locations/{location}/ruleSets/{rule_set}" + }; + + // The resource name of the rule set. Managed internally. + // Format: + // projects/{project_number}/locations/{location}/ruleSet/{rule_set_id}. + // + // The name is ignored when creating a rule set. + string name = 6; + + // Short description of the rule-set. + string description = 1; + + // Source of the rules i.e., customer name. + string source = 2; + + // List of rules given by the customer. + repeated Rule rules = 3; +} + +// Represents the rule for a content warehouse trigger. +message Rule { + enum TriggerType { + UNKNOWN = 0; + + // Trigger for create document action. + ON_CREATE = 1; + + // Trigger for update document action. + ON_UPDATE = 4; + } + + // Short description of the rule and its context. + string description = 1; + + // ID of the rule. It has to be unique across all the examples. + // This is managed internally. + string rule_id = 2; + + // Identifies the trigger type for running the policy. + TriggerType trigger_type = 3; + + // Represents the conditional expression to be evaluated. + // Expression should evaluate to a boolean result. + // When the condition is true actions are executed. + // Example: user_role = "hsbc_role_1" AND doc.salary > 20000 + string condition = 4; + + // List of actions that are executed when the rule is satisfied. + repeated Action actions = 5; +} + +// Represents the action triggered by Rule Engine when the rule is true. +message Action { + // ID of the action. Managed internally. + string action_id = 1; + + oneof action { + // Action triggering access control operations. + AccessControlAction access_control = 2; + + // Action triggering data validation operations. + DataValidationAction data_validation = 3; + + // Action triggering data update operations. + DataUpdateAction data_update = 4; + + // Action triggering create document link operation. + AddToFolderAction add_to_folder = 5; + + // Action publish to Pub/Sub operation. + PublishAction publish_to_pub_sub = 6; + + // Action removing a document from a folder. + RemoveFromFolderAction remove_from_folder_action = 9; + + // Action deleting the document. + DeleteDocumentAction delete_document_action = 10; + } +} + +// Represents the action responsible for access control list management +// operations. +message AccessControlAction { + // Type of ACL modification operation. + enum OperationType { + UNKNOWN = 0; + + // Adds newly given policy bindings in the existing bindings list. + ADD_POLICY_BINDING = 1; + + // Removes newly given policy bindings from the existing bindings list. + REMOVE_POLICY_BINDING = 2; + + // Replaces existing policy bindings with the given policy binding list + REPLACE_POLICY_BINDING = 3; + } + + // Identifies the type of operation. + OperationType operation_type = 1; + + // Represents the new policy from which bindings are added, removed or + // replaced based on the type of the operation. the policy is limited to a few + // 10s of KB. + google.iam.v1.Policy policy = 2; +} + +// Represents the action responsible for data validation operations. +message DataValidationAction { + // Map of (K, V) -> (field, string condition to be evaluated on the field) + // E.g., ("age", "age > 18 && age < 60") entry triggers validation of field + // age with the given condition. Map entries will be ANDed during validation. + map conditions = 1; +} + +// Represents the action responsible for properties update operations. +message DataUpdateAction { + // Map of (K, V) -> (valid name of the field, new value of the field) + // E.g., ("age", "60") entry triggers update of field age with a value of 60. + // If the field is not present then new entry is added. + // During update action execution, value strings will be casted to + // appropriate types. + map entries = 1; +} + +// Represents the action responsible for adding document under a folder. +message AddToFolderAction { + // Names of the folder under which new document is to be added. + // Format: + // projects/{project_number}/locations/{location}/documents/{document_id}. + repeated string folders = 1 [(google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Document" + }]; +} + +// Represents the action responsible for remove a document from a specific +// folder. +message RemoveFromFolderAction { + // Condition of the action to be executed. + string condition = 1; + + // Name of the folder under which new document is to be added. + // Format: + // projects/{project_number}/locations/{location}/documents/{document_id}. + string folder = 2 [(google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Document" + }]; +} + +// Represents the action responsible for publishing messages to a Pub/Sub topic. +message PublishAction { + // The topic id in the Pub/Sub service for which messages will be published + // to. + string topic_id = 1; + + // Messages to be published. + repeated string messages = 2; +} + +// Represents the action responsible for deleting the document. +message DeleteDocumentAction { + // Boolean field to select between hard vs soft delete options. + // Set 'true' for 'hard delete' and 'false' for 'soft delete'. + bool enable_hard_delete = 1; +} + +// Records the output of Rule Engine including rule evaluation and actions +// result. +message RuleEngineOutput { + // Name of the document against which the rules and actions were evaluated. + string document_name = 3; + + // Output from Rule Evaluator containing matched, unmatched and invalid rules. + RuleEvaluatorOutput rule_evaluator_output = 1; + + // Output from Action Executor containing rule and corresponding actions + // execution result. + ActionExecutorOutput action_executor_output = 2; +} + +// Represents the output of the Rule Evaluator. +message RuleEvaluatorOutput { + // List of rules fetched from database for the given request trigger type. + repeated Rule triggered_rules = 1; + + // A subset of triggered rules that are evaluated true for a given request. + repeated Rule matched_rules = 2; + + // A subset of triggered rules that failed the validation check(s) after + // parsing. + repeated InvalidRule invalid_rules = 3; +} + +// A triggered rule that failed the validation check(s) after parsing. +message InvalidRule { + // Triggered rule. + Rule rule = 1; + + // Validation error on a parsed expression. + string error = 2; +} + +// Represents the output of the Action Executor. +message ActionExecutorOutput { + // List of rule and corresponding actions result. + repeated RuleActionsPair rule_actions_pairs = 1; +} + +// Represents a rule and outputs of associated actions. +message RuleActionsPair { + // Represents the rule. + Rule rule = 1; + + // Outputs of executing the actions associated with the above rule. + repeated ActionOutput action_outputs = 2; +} + +// Represents the result of executing an action. +message ActionOutput { + // Represents execution state of the action. + enum State { + UNKNOWN = 0; + + // State indicating action executed successfully. + ACTION_SUCCEEDED = 1; + + // State indicating action failed. + ACTION_FAILED = 2; + + // State indicating action timed out. + ACTION_TIMED_OUT = 3; + + // State indicating action is pending. + ACTION_PENDING = 4; + } + + // ID of the action. + string action_id = 1; + + // State of an action. + State action_state = 2; + + // Action execution output message. + string output_message = 3; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service.proto new file mode 100644 index 00000000000..091367eabee --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service.proto @@ -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 +// +// 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.contentwarehouse.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/cloud/contentwarehouse/v1/rule_engine.proto"; +import "google/cloud/contentwarehouse/v1/ruleset_service_request.proto"; +import "google/protobuf/empty.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "RuleSetServiceProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// Service to manage customer specific RuleSets. +service RuleSetService { + option (google.api.default_host) = "contentwarehouse.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a ruleset. + rpc CreateRuleSet(CreateRuleSetRequest) returns (RuleSet) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/ruleSets" + body: "rule_set" + }; + option (google.api.method_signature) = "parent,rule_set"; + } + + // Gets a ruleset. Returns NOT_FOUND if the ruleset does not exist. + rpc GetRuleSet(GetRuleSetRequest) returns (RuleSet) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/ruleSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a ruleset. Returns INVALID_ARGUMENT if the name of the ruleset + // is non-empty and does not equal the existing name. + rpc UpdateRuleSet(UpdateRuleSetRequest) returns (RuleSet) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/ruleSets/*}" + body: "*" + }; + option (google.api.method_signature) = "name,rule_set"; + } + + // Deletes a ruleset. Returns NOT_FOUND if the document does not exist. + rpc DeleteRuleSet(DeleteRuleSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/ruleSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists rulesets. + rpc ListRuleSets(ListRuleSetsRequest) returns (ListRuleSetsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/ruleSets" + }; + option (google.api.method_signature) = "parent"; + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto new file mode 100644 index 00000000000..61d12510680 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto @@ -0,0 +1,118 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/contentwarehouse/v1/rule_engine.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "RuleSetServiceRequestProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// Request message for RuleSetService.CreateRuleSet. +message CreateRuleSetRequest { + // Required. The parent name. + // Format: projects/{project_number}/locations/{location}. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Location" + } + ]; + + // Required. The rule set to create. + RuleSet rule_set = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for RuleSetService.GetRuleSet. +message GetRuleSetRequest { + // Required. The name of the rule set to retrieve. + // Format: + // projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/RuleSet" + } + ]; +} + +// Request message for RuleSetService.UpdateRuleSet. +message UpdateRuleSetRequest { + // Required. The name of the rule set to update. + // Format: + // projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/RuleSet" + } + ]; + + // Required. The rule set to update. + RuleSet rule_set = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for RuleSetService.DeleteRuleSet. +message DeleteRuleSetRequest { + // Required. The name of the rule set to delete. + // Format: + // projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/RuleSet" + } + ]; +} + +// Request message for RuleSetService.ListRuleSets. +message ListRuleSetsRequest { + // Required. The parent, which owns this collection of document. + // Format: projects/{project_number}/locations/{location}. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Location" + } + ]; + + // The maximum number of rule sets to return. The service may return + // fewer than this value. + // If unspecified, at most 50 rule sets will be returned. + // The maximum value is 1000; values above 1000 will be coerced to 1000. + int32 page_size = 2; + + // A page token, received from a previous `ListRuleSets` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListRuleSets` + // must match the call that provided the page token. + string page_token = 3; +} + +// Response message for RuleSetService.ListRuleSets. +message ListRuleSetsResponse { + // The rule sets from the specified parent. + repeated RuleSet rule_sets = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset.proto new file mode 100644 index 00000000000..d4f23e0571e --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset.proto @@ -0,0 +1,58 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.contentwarehouse.v1; + +import "google/api/resource.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "SynonymSetProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// Represents a list of synonyms for a given context. +// For example a context "sales" could contain: +// Synonym 1: sale, invoice, bill, order +// Synonym 2: money, credit, finance, payment +// Synonym 3: shipping, freight, transport +// Each SynonymSets should be disjoint +message SynonymSet { + option (google.api.resource) = { + type: "contentwarehouse.googleapis.com/SynonymSet" + pattern: "projects/{project}/locations/{location}/synonymSets/{context}" + }; + + // Represents a list of words given by the customer + // All these words are synonyms of each other. + message Synonym { + // For example: sale, invoice, bill, order + repeated string words = 1; + } + + // The resource name of the SynonymSet + // This is mandatory for google.api.resource. + // Format: + // projects/{project_number}/locations/{location}/synonymSets/{context}. + string name = 1; + + // This is a freeform field. Example contexts can be "sales," "engineering," + // "real estate," "accounting," etc. + // The context can be supplied during search requests. + string context = 2; + + // List of Synonyms for the context. + repeated Synonym synonyms = 3; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service.proto new file mode 100644 index 00000000000..39acfd112ae --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service.proto @@ -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 +// +// 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.contentwarehouse.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/cloud/contentwarehouse/v1/synonymset.proto"; +import "google/cloud/contentwarehouse/v1/synonymset_service_request.proto"; +import "google/protobuf/empty.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "SynonymSetServiceProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// A Service that manage/custom customer specified SynonymSets. +service SynonymSetService { + option (google.api.default_host) = "contentwarehouse.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a SynonymSet for a single context. + // Throws an ALREADY_EXISTS exception if a synonymset already exists + // for the context. + rpc CreateSynonymSet(CreateSynonymSetRequest) returns (SynonymSet) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/synonymSets" + body: "synonym_set" + }; + option (google.api.method_signature) = "parent,synonym_set"; + } + + // Gets a SynonymSet for a particular context. + // Throws a NOT_FOUND exception if the Synonymset + // does not exist + rpc GetSynonymSet(GetSynonymSetRequest) returns (SynonymSet) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/synonymSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Remove the existing SynonymSet for the context and replaces it + // with a new one. + // Throws a NOT_FOUND exception if the SynonymSet is not found. + rpc UpdateSynonymSet(UpdateSynonymSetRequest) returns (SynonymSet) { + option (google.api.http) = { + patch: "/v1/{name=projects/*/locations/*/synonymSets/*}" + body: "synonym_set" + }; + option (google.api.method_signature) = "name,synonym_set"; + } + + // Deletes a SynonymSet for a given context. + // Throws a NOT_FOUND exception if the SynonymSet is not found. + rpc DeleteSynonymSet(DeleteSynonymSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/synonymSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Returns all SynonymSets (for all contexts) for the specified location. + rpc ListSynonymSets(ListSynonymSetsRequest) returns (ListSynonymSetsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/synonymSets" + }; + option (google.api.method_signature) = "parent"; + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto new file mode 100644 index 00000000000..8d1955456d3 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto @@ -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 +// +// 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.contentwarehouse.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/contentwarehouse/v1/synonymset.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; +option java_multiple_files = true; +option java_outer_classname = "SynonymSetServiceRequestProto"; +option java_package = "com.google.cloud.contentwarehouse.v1"; + +// Request message for SynonymSetService.CreateSynonymSet. +message CreateSynonymSetRequest { + // Required. The parent name. + // Format: projects/{project_number}/locations/{location}. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Location" + } + ]; + + // Required. The synonymSet to be created for a context + SynonymSet synonym_set = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for SynonymSetService.GetSynonymSet. +// Will return synonymSet for a certain context. +message GetSynonymSetRequest { + // Required. The name of the synonymSet to retrieve + // Format: + // projects/{project_number}/locations/{location}/synonymSets/{context}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/SynonymSet" + } + ]; +} + +// Request message for SynonymSetService.ListSynonymSets. +// Will return all synonymSets belonging to the customer project. +message ListSynonymSetsRequest { + // Required. The parent name. + // Format: projects/{project_number}/locations/{location}. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/Location" + } + ]; + + // The maximum number of synonymSets to return. The service may return + // fewer than this value. + // If unspecified, at most 50 rule sets will be returned. + // The maximum value is 1000; values above 1000 will be coerced to 1000. + int32 page_size = 2; + + // A page token, received from a previous `ListSynonymSets` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListSynonymSets` + // must match the call that provided the page token. + string page_token = 3; +} + +// Response message for SynonymSetService.ListSynonymSets. +message ListSynonymSetsResponse { + // The synonymSets from the specified parent. + repeated SynonymSet synonym_sets = 1; + + // A page token, received from a previous `ListSynonymSets` call. + // Provide this to retrieve the subsequent page. + string next_page_token = 2; +} + +// Request message for SynonymSetService.UpdateSynonymSet. +// Removes the SynonymSet for the specified context and replaces +// it with the SynonymSet in this request. +message UpdateSynonymSetRequest { + // Required. The name of the synonymSet to update + // Format: + // projects/{project_number}/locations/{location}/synonymSets/{context}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/SynonymSet" + } + ]; + + // Required. The synonymSet to be updated for the customer + SynonymSet synonym_set = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for SynonymSetService.DeleteSynonymSet. +message DeleteSynonymSetRequest { + // Required. The name of the synonymSet to delete + // Format: + // projects/{project_number}/locations/{location}/synonymSets/{context}. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "contentwarehouse.googleapis.com/SynonymSet" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/barcode.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/barcode.proto new file mode 100644 index 00000000000..bb841771ade --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/barcode.proto @@ -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 +// +// 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.documentai.v1; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "BarcodeProto"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// Encodes the detailed information of a barcode. +message Barcode { + // Format of a barcode. + // The supported formats are: + // + // - `CODE_128`: Code 128 type. + // - `CODE_39`: Code 39 type. + // - `CODE_93`: Code 93 type. + // - `CODABAR`: Codabar type. + // - `DATA_MATRIX`: 2D Data Matrix type. + // - `ITF`: ITF type. + // - `EAN_13`: EAN-13 type. + // - `EAN_8`: EAN-8 type. + // - `QR_CODE`: 2D QR code type. + // - `UPC_A`: UPC-A type. + // - `UPC_E`: UPC-E type. + // - `PDF417`: PDF417 type. + // - `AZTEC`: 2D Aztec code type. + // - `DATABAR`: GS1 DataBar code type. + string format = 1; + + // Value format describes the format of the value that a barcode + // encodes. + // The supported formats are: + // + // - `CONTACT_INFO`: Contact information. + // - `EMAIL`: Email address. + // - `ISBN`: ISBN identifier. + // - `PHONE`: Phone number. + // - `PRODUCT`: Product. + // - `SMS`: SMS message. + // - `TEXT`: Text string. + // - `URL`: URL address. + // - `WIFI`: Wifi information. + // - `GEO`: Geo-localization. + // - `CALENDAR_EVENT`: Calendar event. + // - `DRIVER_LICENSE`: Driver's license. + string value_format = 2; + + // Raw value encoded in the barcode. + // For example: `'MEBKM:TITLE:Google;URL:https://www.google.com;;'`. + string raw_value = 3; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document.proto new file mode 100644 index 00000000000..c4fbb21ceca --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document.proto @@ -0,0 +1,820 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.documentai.v1; + +import "google/api/field_behavior.proto"; +import "google/cloud/documentai/v1/barcode.proto"; +import "google/cloud/documentai/v1/geometry.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/date.proto"; +import "google/type/datetime.proto"; +import "google/type/money.proto"; +import "google/type/postal_address.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// Document represents the canonical document resource in Document AI. It is an +// interchange format that provides insights into documents and allows for +// collaboration between users and Document AI to iterate and optimize for +// quality. +message Document { + // For a large document, sharding may be performed to produce several + // document shards. Each document shard contains this field to detail which + // shard it is. + message ShardInfo { + // The 0-based index of this shard. + int64 shard_index = 1; + + // Total number of shards. + int64 shard_count = 2; + + // The index of the first character in [Document.text][google.cloud.documentai.v1.Document.text] in the overall + // document global text. + int64 text_offset = 3; + } + + // Annotation for common text style attributes. This adheres to CSS + // conventions as much as possible. + message Style { + // Font size with unit. + message FontSize { + // Font size for the text. + float size = 1; + + // Unit for the font size. Follows CSS naming (in, px, pt, etc.). + string unit = 2; + } + + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. + TextAnchor text_anchor = 1; + + // Text color. + google.type.Color color = 2; + + // Text background color. + google.type.Color background_color = 3; + + // Font weight. Possible values are normal, bold, bolder, and lighter. + // https://www.w3schools.com/cssref/pr_font_weight.asp + string font_weight = 4; + + // Text style. Possible values are normal, italic, and oblique. + // https://www.w3schools.com/cssref/pr_font_font-style.asp + string text_style = 5; + + // Text decoration. Follows CSS standard. + // + // https://www.w3schools.com/cssref/pr_text_text-decoration.asp + string text_decoration = 6; + + // Font size. + FontSize font_size = 7; + + // Font family such as `Arial`, `Times New Roman`. + // https://www.w3schools.com/cssref/pr_font_font-family.asp + string font_family = 8; + } + + // A page in a [Document][google.cloud.documentai.v1.Document]. + message Page { + // Dimension for the page. + message Dimension { + // Page width. + float width = 1; + + // Page height. + float height = 2; + + // Dimension unit. + string unit = 3; + } + + // Rendered image contents for this page. + message Image { + // Raw byte content of the image. + bytes content = 1; + + // Encoding mime type for the image. + string mime_type = 2; + + // Width of the image in pixels. + int32 width = 3; + + // Height of the image in pixels. + int32 height = 4; + } + + // Representation for transformation matrix, intended to be compatible and + // used with OpenCV format for image manipulation. + message Matrix { + // Number of rows in the matrix. + int32 rows = 1; + + // Number of columns in the matrix. + int32 cols = 2; + + // This encodes information about what data type the matrix uses. + // For example, 0 (CV_8U) is an unsigned 8-bit image. For the full list + // of OpenCV primitive data types, please refer to + // https://docs.opencv.org/4.3.0/d1/d1b/group__core__hal__interface.html + int32 type = 3; + + // The matrix data. + bytes data = 4; + } + + // Visual element describing a layout unit on a page. + message Layout { + // Detected human reading orientation. + enum Orientation { + // Unspecified orientation. + ORIENTATION_UNSPECIFIED = 0; + + // Orientation is aligned with page up. + PAGE_UP = 1; + + // Orientation is aligned with page right. + // Turn the head 90 degrees clockwise from upright to read. + PAGE_RIGHT = 2; + + // Orientation is aligned with page down. + // Turn the head 180 degrees from upright to read. + PAGE_DOWN = 3; + + // Orientation is aligned with page left. + // Turn the head 90 degrees counterclockwise from upright to read. + PAGE_LEFT = 4; + } + + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. + TextAnchor text_anchor = 1; + + // Confidence of the current [Layout][google.cloud.documentai.v1.Document.Page.Layout] within context of the object this + // layout is for. e.g. confidence can be for a single token, a table, + // a visual element, etc. depending on context. Range `[0, 1]`. + float confidence = 2; + + // The bounding polygon for the [Layout][google.cloud.documentai.v1.Document.Page.Layout]. + BoundingPoly bounding_poly = 3; + + // Detected orientation for the [Layout][google.cloud.documentai.v1.Document.Page.Layout]. + Orientation orientation = 4; + } + + // A block has a set of lines (collected into paragraphs) that have a + // common line-spacing and orientation. + message Block { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Block][google.cloud.documentai.v1.Document.Page.Block]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + + // The history of this annotation. + Provenance provenance = 3 [deprecated = true]; + } + + // A collection of lines that a human would perceive as a paragraph. + message Paragraph { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1.Document.Page.Paragraph]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + + // The history of this annotation. + Provenance provenance = 3 [deprecated = true]; + } + + // A collection of tokens that a human would perceive as a line. + // Does not cross column boundaries, can be horizontal, vertical, etc. + message Line { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Line][google.cloud.documentai.v1.Document.Page.Line]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + + // The history of this annotation. + Provenance provenance = 3 [deprecated = true]; + } + + // A detected token. + message Token { + // Detected break at the end of a [Token][google.cloud.documentai.v1.Document.Page.Token]. + message DetectedBreak { + // Enum to denote the type of break found. + enum Type { + // Unspecified break type. + TYPE_UNSPECIFIED = 0; + + // A single whitespace. + SPACE = 1; + + // A wider whitespace. + WIDE_SPACE = 2; + + // A hyphen that indicates that a token has been split across lines. + HYPHEN = 3; + } + + // Detected break type. + Type type = 1; + } + + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Token][google.cloud.documentai.v1.Document.Page.Token]. + Layout layout = 1; + + // Detected break at the end of a [Token][google.cloud.documentai.v1.Document.Page.Token]. + DetectedBreak detected_break = 2; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 3; + + // The history of this annotation. + Provenance provenance = 4 [deprecated = true]; + } + + // A detected symbol. + message Symbol { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Symbol][google.cloud.documentai.v1.Document.Page.Symbol]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + } + + // Detected non-text visual elements e.g. checkbox, signature etc. on the + // page. + message VisualElement { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1.Document.Page.VisualElement]. + Layout layout = 1; + + // Type of the [VisualElement][google.cloud.documentai.v1.Document.Page.VisualElement]. + string type = 2; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 3; + } + + // A table representation similar to HTML table structure. + message Table { + // A row of table cells. + message TableRow { + // Cells that make up this row. + repeated TableCell cells = 1; + } + + // A cell representation inside the table. + message TableCell { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1.Document.Page.Table.TableCell]. + Layout layout = 1; + + // How many rows this cell spans. + int32 row_span = 2; + + // How many columns this cell spans. + int32 col_span = 3; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 4; + } + + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Table][google.cloud.documentai.v1.Document.Page.Table]. + Layout layout = 1; + + // Header rows of the table. + repeated TableRow header_rows = 2; + + // Body rows of the table. + repeated TableRow body_rows = 3; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 4; + + // The history of this table. + Provenance provenance = 5; + } + + // A form field detected on the page. + message FormField { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1.Document.Page.FormField] name. e.g. `Address`, `Email`, + // `Grand total`, `Phone number`, etc. + Layout field_name = 1; + + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1.Document.Page.FormField] value. + Layout field_value = 2; + + // A list of detected languages for name together with confidence. + repeated DetectedLanguage name_detected_languages = 3; + + // A list of detected languages for value together with confidence. + repeated DetectedLanguage value_detected_languages = 4; + + // If the value is non-textual, this field represents the type. Current + // valid values are: + // - blank (this indicates the field_value is normal text) + // - "unfilled_checkbox" + // - "filled_checkbox" + string value_type = 5; + + // Created for Labeling UI to export key text. + // If corrections were made to the text identified by the + // `field_name.text_anchor`, this field will contain the correction. + string corrected_key_text = 6; + + // Created for Labeling UI to export value text. + // If corrections were made to the text identified by the + // `field_value.text_anchor`, this field will contain the correction. + string corrected_value_text = 7; + + // The history of this annotation. + Provenance provenance = 8; + } + + // A detected barcode. + message DetectedBarcode { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [DetectedBarcode][google.cloud.documentai.v1.Document.Page.DetectedBarcode]. + Layout layout = 1; + + // Detailed barcode information of the [DetectedBarcode][google.cloud.documentai.v1.Document.Page.DetectedBarcode]. + Barcode barcode = 2; + } + + // Detected language for a structural component. + message DetectedLanguage { + // The BCP-47 language code, such as `en-US` or `sr-Latn`. For more + // information, see + // https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 1; + + // Confidence of detected language. Range `[0, 1]`. + float confidence = 2; + } + + // Image Quality Scores for the page image + message ImageQualityScores { + // Image Quality Defects + message DetectedDefect { + // Name of the defect type. Supported values are: + // + // - `quality/defect_blurry` + // - `quality/defect_noisy` + // - `quality/defect_dark` + // - `quality/defect_faint` + // - `quality/defect_text_too_small` + // - `quality/defect_document_cutoff` + // - `quality/defect_text_cutoff` + // - `quality/defect_glare` + string type = 1; + + // Confidence of detected defect. Range `[0, 1]` where 1 indicates + // strong confidence of that the defect exists. + float confidence = 2; + } + + // The overall quality score. Range `[0, 1]` where 1 is perfect quality. + float quality_score = 1; + + // A list of detected defects. + repeated DetectedDefect detected_defects = 2; + } + + // 1-based index for current [Page][google.cloud.documentai.v1.Document.Page] in a parent [Document][google.cloud.documentai.v1.Document]. + // Useful when a page is taken out of a [Document][google.cloud.documentai.v1.Document] for individual + // processing. + int32 page_number = 1; + + // Rendered image for this page. This image is preprocessed to remove any + // skew, rotation, and distortions such that the annotation bounding boxes + // can be upright and axis-aligned. + Image image = 13; + + // Transformation matrices that were applied to the original document image + // to produce [Page.image][google.cloud.documentai.v1.Document.Page.image]. + repeated Matrix transforms = 14; + + // Physical dimension of the page. + Dimension dimension = 2; + + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the page. + Layout layout = 3; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 4; + + // A list of visually detected text blocks on the page. + // A block has a set of lines (collected into paragraphs) that have a common + // line-spacing and orientation. + repeated Block blocks = 5; + + // A list of visually detected text paragraphs on the page. + // A collection of lines that a human would perceive as a paragraph. + repeated Paragraph paragraphs = 6; + + // A list of visually detected text lines on the page. + // A collection of tokens that a human would perceive as a line. + repeated Line lines = 7; + + // A list of visually detected tokens on the page. + repeated Token tokens = 8; + + // A list of detected non-text visual elements e.g. checkbox, + // signature etc. on the page. + repeated VisualElement visual_elements = 9; + + // A list of visually detected tables on the page. + repeated Table tables = 10; + + // A list of visually detected form fields on the page. + repeated FormField form_fields = 11; + + // A list of visually detected symbols on the page. + repeated Symbol symbols = 12; + + // A list of detected barcodes. + repeated DetectedBarcode detected_barcodes = 15; + + // Image Quality Scores. + ImageQualityScores image_quality_scores = 17; + + // The history of this page. + Provenance provenance = 16 [deprecated = true]; + } + + // An entity that could be a phrase in the text or a property that belongs to + // the document. It is a known entity type, such as a person, an organization, + // or location. + message Entity { + // Parsed and normalized entity value. + message NormalizedValue { + // An optional structured entity value. + // Must match entity type defined in schema if + // known. If this field is present, the `text` field could also be + // populated. + oneof structured_value { + // Money value. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/money.proto + google.type.Money money_value = 2; + + // Date value. Includes year, month, day. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/date.proto + google.type.Date date_value = 3; + + // DateTime value. Includes date, time, and timezone. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto + google.type.DateTime datetime_value = 4; + + // Postal address. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto + google.type.PostalAddress address_value = 5; + + // Boolean value. Can be used for entities with binary values, or for + // checkboxes. + bool boolean_value = 6; + + // Integer value. + int32 integer_value = 7; + + // Float value. + float float_value = 8; + } + + // Optional. An optional field to store a normalized string. + // For some entity types, one of respective `structured_value` fields may + // also be populated. Also not all the types of `structured_value` will be + // normalized. For example, some processors may not generate float + // or int normalized text by default. + // + // Below are sample formats mapped to structured values. + // + // - Money/Currency type (`money_value`) is in the ISO 4217 text format. + // - Date type (`date_value`) is in the ISO 8601 text format. + // - Datetime type (`datetime_value`) is in the ISO 8601 text format. + string text = 1 [(google.api.field_behavior) = OPTIONAL]; + } + + // Optional. Provenance of the entity. + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. + TextAnchor text_anchor = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Entity type from a schema e.g. `Address`. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`. + string mention_text = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Deprecated. Use `id` field instead. + string mention_id = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Confidence of detected Schema entity. Range `[0, 1]`. + float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Represents the provenance of this entity wrt. the location on the + // page where it was found. + PageAnchor page_anchor = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Canonical id. This will be a unique value in the entity list + // for this document. + string id = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Normalized entity value. Absent if the extracted value could not be + // converted or the type (e.g. address) is not supported for certain + // parsers. This field is also only populated for certain supported document + // types. + NormalizedValue normalized_value = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Entities can be nested to form a hierarchical data structure representing + // the content in the document. + repeated Entity properties = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The history of this annotation. + Provenance provenance = 11 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Whether the entity will be redacted for de-identification purposes. + bool redacted = 12 [(google.api.field_behavior) = OPTIONAL]; + } + + // Relationship between [Entities][google.cloud.documentai.v1.Document.Entity]. + message EntityRelation { + // Subject entity id. + string subject_id = 1; + + // Object entity id. + string object_id = 2; + + // Relationship description. + string relation = 3; + } + + // Text reference indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. + message TextAnchor { + // A text segment in the [Document.text][google.cloud.documentai.v1.Document.text]. The indices may be out of bounds + // which indicate that the text extends into another document shard for + // large sharded documents. See [ShardInfo.text_offset][google.cloud.documentai.v1.Document.ShardInfo.text_offset] + message TextSegment { + // [TextSegment][google.cloud.documentai.v1.Document.TextAnchor.TextSegment] start UTF-8 char index in the [Document.text][google.cloud.documentai.v1.Document.text]. + int64 start_index = 1; + + // [TextSegment][google.cloud.documentai.v1.Document.TextAnchor.TextSegment] half open end UTF-8 char index in the + // [Document.text][google.cloud.documentai.v1.Document.text]. + int64 end_index = 2; + } + + // The text segments from the [Document.text][google.cloud.documentai.v1.Document.text]. + repeated TextSegment text_segments = 1; + + // Contains the content of the text span so that users do + // not have to look it up in the text_segments. It is always + // populated for formFields. + string content = 2; + } + + // Referencing the visual context of the entity in the [Document.pages][google.cloud.documentai.v1.Document.pages]. + // Page anchors can be cross-page, consist of multiple bounding polygons and + // optionally reference specific layout element types. + message PageAnchor { + // Represents a weak reference to a page element within a document. + message PageRef { + // The type of layout that is being referenced. + enum LayoutType { + // Layout Unspecified. + LAYOUT_TYPE_UNSPECIFIED = 0; + + // References a [Page.blocks][google.cloud.documentai.v1.Document.Page.blocks] element. + BLOCK = 1; + + // References a [Page.paragraphs][google.cloud.documentai.v1.Document.Page.paragraphs] element. + PARAGRAPH = 2; + + // References a [Page.lines][google.cloud.documentai.v1.Document.Page.lines] element. + LINE = 3; + + // References a [Page.tokens][google.cloud.documentai.v1.Document.Page.tokens] element. + TOKEN = 4; + + // References a [Page.visual_elements][google.cloud.documentai.v1.Document.Page.visual_elements] element. + VISUAL_ELEMENT = 5; + + // Refrrences a [Page.tables][google.cloud.documentai.v1.Document.Page.tables] element. + TABLE = 6; + + // References a [Page.form_fields][google.cloud.documentai.v1.Document.Page.form_fields] element. + FORM_FIELD = 7; + } + + // Required. Index into the [Document.pages][google.cloud.documentai.v1.Document.pages] element, for example using + // [Document.pages][page_refs.page] to locate the related page element. + // This field is skipped when its value is the default 0. See + // https://developers.google.com/protocol-buffers/docs/proto3#json. + int64 page = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The type of the layout element that is being referenced if any. + LayoutType layout_type = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Deprecated. Use [PageRef.bounding_poly][google.cloud.documentai.v1.Document.PageAnchor.PageRef.bounding_poly] instead. + string layout_id = 3 [ + deprecated = true, + (google.api.field_behavior) = OPTIONAL + ]; + + // Optional. Identifies the bounding polygon of a layout element on the page. + BoundingPoly bounding_poly = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Confidence of detected page element, if applicable. Range `[0, 1]`. + float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; + } + + // One or more references to visual page elements + repeated PageRef page_refs = 1; + } + + // Structure to identify provenance relationships between annotations in + // different revisions. + message Provenance { + // The parent element the current element is based on. Used for + // referencing/aligning, removal and replacement operations. + message Parent { + // The index of the index into current revision's parent_ids list. + int32 revision = 1; + + // The index of the parent item in the corresponding item list (eg. list + // of entities, properties within entities, etc.) in the parent revision. + int32 index = 3; + + // The id of the parent provenance. + int32 id = 2 [deprecated = true]; + } + + // If a processor or agent does an explicit operation on existing elements. + enum OperationType { + // Operation type unspecified. If no operation is specified a provenance + // entry is simply used to match against a `parent`. + OPERATION_TYPE_UNSPECIFIED = 0; + + // Add an element. + ADD = 1; + + // Remove an element identified by `parent`. + REMOVE = 2; + + // Replace an element identified by `parent`. + REPLACE = 3; + + // Request human review for the element identified by `parent`. + EVAL_REQUESTED = 4; + + // Element is reviewed and approved at human review, confidence will be + // set to 1.0. + EVAL_APPROVED = 5; + + // Element is skipped in the validation process. + EVAL_SKIPPED = 6; + } + + // The index of the revision that produced this element. + int32 revision = 1; + + // The Id of this operation. Needs to be unique within the scope of the + // revision. + int32 id = 2 [deprecated = true]; + + // References to the original elements that are replaced. + repeated Parent parents = 3; + + // The type of provenance operation. + OperationType type = 4; + } + + // Contains past or forward revisions of this document. + message Revision { + // Human Review information of the document. + message HumanReview { + // Human review state. e.g. `requested`, `succeeded`, `rejected`. + string state = 1; + + // A message providing more details about the current state of processing. + // For example, the rejection reason when the state is `rejected`. + string state_message = 2; + } + + // Who/what made the change + oneof source { + // If the change was made by a person specify the name or id of that + // person. + string agent = 4; + + // If the annotation was made by processor identify the processor by its + // resource name. + string processor = 5; + } + + // Id of the revision. Unique within the context of the document. + string id = 1; + + // The revisions that this revision is based on. This can include one or + // more parent (when documents are merged.) This field represents the + // index into the `revisions` field. + repeated int32 parent = 2 [deprecated = true]; + + // The revisions that this revision is based on. Must include all the ids + // that have anything to do with this revision - eg. there are + // `provenance.parent.revision` fields that index into this field. + repeated string parent_ids = 7; + + // The time that the revision was created. + google.protobuf.Timestamp create_time = 3; + + // Human Review information of this revision. + HumanReview human_review = 6; + } + + // This message is used for text changes aka. OCR corrections. + message TextChange { + // Provenance of the correction. + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. There can only be a + // single `TextAnchor.text_segments` element. If the start and + // end index of the text segment are the same, the text change is inserted + // before that index. + TextAnchor text_anchor = 1; + + // The text that replaces the text identified in the `text_anchor`. + string changed_text = 2; + + // The history of this annotation. + repeated Provenance provenance = 3 [deprecated = true]; + } + + // Original source document from the user. + oneof source { + // Optional. Currently supports Google Cloud Storage URI of the form + // `gs://bucket_name/object_name`. Object versioning is not supported. + // See [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris) for more + // info. + string uri = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Inline document content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + bytes content = 2 [(google.api.field_behavior) = OPTIONAL]; + } + + // An IANA published MIME type (also referred to as media type). For more + // information, see + // https://www.iana.org/assignments/media-types/media-types.xhtml. + string mime_type = 3; + + // Optional. UTF-8 encoded text in reading order from the document. + string text = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Placeholder. Styles for the [Document.text][google.cloud.documentai.v1.Document.text]. + repeated Style text_styles = 5; + + // Visual page layout for the [Document][google.cloud.documentai.v1.Document]. + repeated Page pages = 6; + + // A list of entities detected on [Document.text][google.cloud.documentai.v1.Document.text]. For document shards, + // entities in this list may cross shard boundaries. + repeated Entity entities = 7; + + // Placeholder. Relationship among [Document.entities][google.cloud.documentai.v1.Document.entities]. + repeated EntityRelation entity_relations = 8; + + // Placeholder. A list of text corrections made to [Document.text][google.cloud.documentai.v1.Document.text]. This + // is usually used for annotating corrections to OCR mistakes. Text changes + // for a given revision may not overlap with each other. + repeated TextChange text_changes = 14; + + // Information about the sharding if this document is sharded part of a larger + // document. If the document is not sharded, this message is not specified. + ShardInfo shard_info = 9; + + // Any error that occurred while processing this document. + google.rpc.Status error = 10; + + // Placeholder. Revision history of this document. + repeated Revision revisions = 13; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_io.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_io.proto new file mode 100644 index 00000000000..d56086336d2 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_io.proto @@ -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 +// +// 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.documentai.v1; + +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentIoProto"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// Payload message of raw document content (bytes). +message RawDocument { + // Inline document content. + bytes content = 1; + + // An IANA MIME type (RFC6838) indicating the nature and format of the + // [content][google.cloud.documentai.v1.RawDocument.content]. + string mime_type = 2; +} + +// Specifies a document stored on Cloud Storage. +message GcsDocument { + // The Cloud Storage object uri. + string gcs_uri = 1; + + // An IANA MIME type (RFC6838) of the content. + string mime_type = 2; +} + +// Specifies a set of documents on Cloud Storage. +message GcsDocuments { + // The list of documents. + repeated GcsDocument documents = 1; +} + +// Specifies all documents on Cloud Storage with a common prefix. +message GcsPrefix { + // The URI prefix. + string gcs_uri_prefix = 1; +} + +// The common config to specify a set of documents used as input. +message BatchDocumentsInputConfig { + // The source. + oneof source { + // The set of documents that match the specified Cloud Storage `gcs_prefix`. + GcsPrefix gcs_prefix = 1; + + // The set of documents individually specified on Cloud Storage. + GcsDocuments gcs_documents = 2; + } +} + +// Config that controls the output of documents. All documents will be written +// as a JSON file. +message DocumentOutputConfig { + // The configuration used when outputting documents. + message GcsOutputConfig { + // The sharding config for the output document. + message ShardingConfig { + // The number of pages per shard. + int32 pages_per_shard = 1; + + // The number of overlapping pages between consecutive shards. + int32 pages_overlap = 2; + } + + // The Cloud Storage uri (a directory) of the output. + string gcs_uri = 1; + + // Specifies which fields to include in the output documents. + // Only supports top level document and pages field so it must be in the + // form of `{document_field_name}` or `pages.{page_field_name}`. + google.protobuf.FieldMask field_mask = 2; + + // Specifies the sharding config for the output document. + ShardingConfig sharding_config = 3; + } + + // The destination of the results. + oneof destination { + // Output config to write the results to Cloud Storage. + GcsOutputConfig gcs_output_config = 1; + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_processor_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_processor_service.proto new file mode 100644 index 00000000000..e748ae1f748 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_processor_service.proto @@ -0,0 +1,801 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.documentai.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/documentai/v1/document.proto"; +import "google/cloud/documentai/v1/document_io.proto"; +import "google/cloud/documentai/v1/document_schema.proto"; +import "google/cloud/documentai/v1/operation_metadata.proto"; +import "google/cloud/documentai/v1/processor.proto"; +import "google/cloud/documentai/v1/processor_type.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProcessorService"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; +option (google.api.resource_definition) = { + type: "documentai.googleapis.com/HumanReviewConfig" + pattern: "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" +}; +option (google.api.resource_definition) = { + type: "documentai.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; + +// Service to call Cloud DocumentAI to process documents according to the +// processor's definition. Processors are built using state-of-the-art Google +// AI such as natural language, computer vision, and translation to extract +// structured information from unstructured or semi-structured documents. +service DocumentProcessorService { + option (google.api.default_host) = "documentai.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Processes a single document. + rpc ProcessDocument(ProcessRequest) returns (ProcessResponse) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*}:process" + body: "*" + additional_bindings { + post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:process" + body: "*" + } + }; + option (google.api.method_signature) = "name"; + } + + // LRO endpoint to batch process many documents. The output is written + // to Cloud Storage as JSON in the [Document] format. + rpc BatchProcessDocuments(BatchProcessRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*}:batchProcess" + body: "*" + additional_bindings { + post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:batchProcess" + body: "*" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "BatchProcessResponse" + metadata_type: "BatchProcessMetadata" + }; + } + + // Fetches processor types. Note that we do not use ListProcessorTypes here + // because it is not paginated. + rpc FetchProcessorTypes(FetchProcessorTypesRequest) returns (FetchProcessorTypesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}:fetchProcessorTypes" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists the processor types that exist. + rpc ListProcessorTypes(ListProcessorTypesRequest) returns (ListProcessorTypesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/processorTypes" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists all processors which belong to this project. + rpc ListProcessors(ListProcessorsRequest) returns (ListProcessorsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/processors" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a processor detail. + rpc GetProcessor(GetProcessorRequest) returns (Processor) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/processors/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a processor version detail. + rpc GetProcessorVersion(GetProcessorVersionRequest) returns (ProcessorVersion) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all versions of a processor. + rpc ListProcessorVersions(ListProcessorVersionsRequest) returns (ListProcessorVersionsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/processors/*}/processorVersions" + }; + option (google.api.method_signature) = "parent"; + } + + // Deletes the processor version, all artifacts under the processor version + // will be deleted. + rpc DeleteProcessorVersion(DeleteProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "DeleteProcessorVersionMetadata" + }; + } + + // Deploys the processor version. + rpc DeployProcessorVersion(DeployProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:deploy" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "DeployProcessorVersionResponse" + metadata_type: "DeployProcessorVersionMetadata" + }; + } + + // Undeploys the processor version. + rpc UndeployProcessorVersion(UndeployProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:undeploy" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "UndeployProcessorVersionResponse" + metadata_type: "UndeployProcessorVersionMetadata" + }; + } + + // Creates a processor from the type processor that the user chose. + // The processor will be at "ENABLED" state by default after its creation. + rpc CreateProcessor(CreateProcessorRequest) returns (Processor) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/processors" + body: "processor" + }; + option (google.api.method_signature) = "parent,processor"; + } + + // Deletes the processor, unloads all deployed model artifacts if it was + // enabled and then deletes all artifacts associated with this processor. + rpc DeleteProcessor(DeleteProcessorRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/processors/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "DeleteProcessorMetadata" + }; + } + + // Enables a processor + rpc EnableProcessor(EnableProcessorRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*}:enable" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "EnableProcessorResponse" + metadata_type: "EnableProcessorMetadata" + }; + } + + // Disables a processor + rpc DisableProcessor(DisableProcessorRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*}:disable" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "DisableProcessorResponse" + metadata_type: "DisableProcessorMetadata" + }; + } + + // Set the default (active) version of a [Processor][google.cloud.documentai.v1.Processor] that will be used in + // [ProcessDocument][google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument] and + // [BatchProcessDocuments][google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments]. + rpc SetDefaultProcessorVersion(SetDefaultProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{processor=projects/*/locations/*/processors/*}:setDefaultProcessorVersion" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "SetDefaultProcessorVersionResponse" + metadata_type: "SetDefaultProcessorVersionMetadata" + }; + } + + // Send a document for Human Review. The input document should be processed by + // the specified processor. + rpc ReviewDocument(ReviewDocumentRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{human_review_config=projects/*/locations/*/processors/*/humanReviewConfig}:reviewDocument" + body: "*" + }; + option (google.api.method_signature) = "human_review_config"; + option (google.longrunning.operation_info) = { + response_type: "ReviewDocumentResponse" + metadata_type: "ReviewDocumentOperationMetadata" + }; + } +} + +// Request message for the process document method. +message ProcessRequest { + // The document payload. + oneof source { + // An inline document proto. + Document inline_document = 4; + + // A raw document content (bytes). + RawDocument raw_document = 5; + } + + // Required. The resource name of the [Processor][google.cloud.documentai.v1.Processor] or + // [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] + // to use for processing. If a [Processor][google.cloud.documentai.v1.Processor] is specified, the server will use + // its [default version][google.cloud.documentai.v1.Processor.default_processor_version]. Format: + // `projects/{project}/locations/{location}/processors/{processor}`, or + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "*" + } + ]; + + // Whether Human Review feature should be skipped for this request. Default to + // false. + bool skip_human_review = 3; + + // Specifies which fields to include in ProcessResponse's document. + // Only supports top level document and pages field so it must be in the form + // of `{document_field_name}` or `pages.{page_field_name}`. + google.protobuf.FieldMask field_mask = 6; +} + +// The status of human review on a processed document. +message HumanReviewStatus { + // The final state of human review on a processed document. + enum State { + // Human review state is unspecified. Most likely due to an internal error. + STATE_UNSPECIFIED = 0; + + // Human review is skipped for the document. This can happen because human + // review is not enabled on the processor or the processing request has + // been set to skip this document. + SKIPPED = 1; + + // Human review validation is triggered and passed, so no review is needed. + VALIDATION_PASSED = 2; + + // Human review validation is triggered and the document is under review. + IN_PROGRESS = 3; + + // Some error happened during triggering human review, see the + // [state_message] for details. + ERROR = 4; + } + + // The state of human review on the processing request. + State state = 1; + + // A message providing more details about the human review state. + string state_message = 2; + + // The name of the operation triggered by the processed document. This field + // is populated only when the [state] is [HUMAN_REVIEW_IN_PROGRESS]. It has + // the same response type and metadata as the long running operation returned + // by [ReviewDocument] method. + string human_review_operation = 3; +} + +// Response message for the process document method. +message ProcessResponse { + // The document payload, will populate fields based on the processor's + // behavior. + Document document = 1; + + // The status of human review on the processed document. + HumanReviewStatus human_review_status = 3; +} + +// Request message for batch process document method. +message BatchProcessRequest { + // Required. The resource name of [Processor][google.cloud.documentai.v1.Processor] or + // [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion]. + // Format: `projects/{project}/locations/{location}/processors/{processor}`, + // or + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "*" + } + ]; + + // The input documents for batch process. + BatchDocumentsInputConfig input_documents = 5; + + // The overall output config for batch process. + DocumentOutputConfig document_output_config = 6; + + // Whether Human Review feature should be skipped for this request. Default to + // false. + bool skip_human_review = 4; +} + +// Response message for batch process document method. +message BatchProcessResponse { + +} + +// The long running operation metadata for batch process method. +message BatchProcessMetadata { + // The status of a each individual document in the batch process. + message IndividualProcessStatus { + // The source of the document, same as the [input_gcs_source] field in the + // request when the batch process started. The batch process is started by + // take snapshot of that document, since a user can move or change that + // document during the process. + string input_gcs_source = 1; + + // The status processing the document. + google.rpc.Status status = 2; + + // The output_gcs_destination (in the request as `output_gcs_destination`) + // of the processed document if it was successful, otherwise empty. + string output_gcs_destination = 3; + + // The status of human review on the processed document. + HumanReviewStatus human_review_status = 5; + } + + // Possible states of the batch processing operation. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // Request operation is waiting for scheduling. + WAITING = 1; + + // Request is being processed. + RUNNING = 2; + + // The batch processing completed successfully. + SUCCEEDED = 3; + + // The batch processing was being cancelled. + CANCELLING = 4; + + // The batch processing was cancelled. + CANCELLED = 5; + + // The batch processing has failed. + FAILED = 6; + } + + // The state of the current batch processing. + State state = 1; + + // A message providing more details about the current state of processing. + // For example, the error message if the operation is failed. + string state_message = 2; + + // The creation time of the operation. + google.protobuf.Timestamp create_time = 3; + + // The last update time of the operation. + google.protobuf.Timestamp update_time = 4; + + // The list of response details of each document. + repeated IndividualProcessStatus individual_process_statuses = 5; +} + +// Request message for fetch processor types. +message FetchProcessorTypesRequest { + // Required. The project of processor type to list. + // The available processor types may depend on the allow-listing on projects. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorType" + } + ]; +} + +// Response message for fetch processor types. +message FetchProcessorTypesResponse { + // The list of processor types. + repeated ProcessorType processor_types = 1; +} + +// Request message for list processor types. +message ListProcessorTypesRequest { + // Required. The location of processor type to list. + // The available processor types may depend on the allow-listing on projects. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorType" + } + ]; + + // The maximum number of processor types to return. + // If unspecified, at most 100 processor types will be returned. + // The maximum value is 500; values above 500 will be coerced to 500. + int32 page_size = 2; + + // Used to retrieve the next page of results, empty if at the end of the list. + string page_token = 3; +} + +// Response message for list processor types. +message ListProcessorTypesResponse { + // The processor types. + repeated ProcessorType processor_types = 1; + + // Points to the next page, otherwise empty. + string next_page_token = 2; +} + +// Request message for list all processors belongs to a project. +message ListProcessorsRequest { + // Required. The parent (project and location) which owns this collection of Processors. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/Processor" + } + ]; + + // The maximum number of processors to return. + // If unspecified, at most 50 processors will be returned. + // The maximum value is 100; values above 100 will be coerced to 100. + int32 page_size = 2; + + // We will return the processors sorted by creation time. The page token + // will point to the next processor. + string page_token = 3; +} + +// Response message for list processors. +message ListProcessorsResponse { + // The list of processors. + repeated Processor processors = 1; + + // Points to the next processor, otherwise empty. + string next_page_token = 2; +} + +// Request message for get processor. +message GetProcessorRequest { + // Required. The processor resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// Request message for get processor version. +message GetProcessorVersionRequest { + // Required. The processor resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Request message for list all processor versions belongs to a processor. +message ListProcessorVersionsRequest { + // Required. The parent (project, location and processor) to list all versions. + // Format: `projects/{project}/locations/{location}/processors/{processor}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorVersion" + } + ]; + + // The maximum number of processor versions to return. + // If unspecified, at most 10 processor versions will be returned. + // The maximum value is 20; values above 20 will be coerced to 20. + int32 page_size = 2; + + // We will return the processor versions sorted by creation time. The page + // token will point to the next processor version. + string page_token = 3; +} + +// Response message for list processors. +message ListProcessorVersionsResponse { + // The list of processors. + repeated ProcessorVersion processor_versions = 1; + + // Points to the next processor, otherwise empty. + string next_page_token = 2; +} + +// Request message for the delete processor version method. +message DeleteProcessorVersionRequest { + // Required. The processor version resource name to be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// The long running operation metadata for delete processor version method. +message DeleteProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for the deploy processor version method. +message DeployProcessorVersionRequest { + // Required. The processor version resource name to be deployed. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Response message for the deploy processor version method. +message DeployProcessorVersionResponse { + +} + +// The long running operation metadata for deploy processor version method. +message DeployProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for the undeploy processor version method. +message UndeployProcessorVersionRequest { + // Required. The processor version resource name to be undeployed. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Response message for the undeploy processor version method. +message UndeployProcessorVersionResponse { + +} + +// The long running operation metadata for the undeploy processor version +// method. +message UndeployProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for create a processor. Notice this request is sent to +// a regionalized backend service, and if the processor type is not available +// on that region, the creation will fail. +message CreateProcessorRequest { + // Required. The parent (project and location) under which to create the processor. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/Processor" + } + ]; + + // Required. The processor to be created, requires [processor_type] and [display_name] + // to be set. Also, the processor is under CMEK if CMEK fields are set. + Processor processor = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for the delete processor method. +message DeleteProcessorRequest { + // Required. The processor resource name to be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// The long running operation metadata for delete processor method. +message DeleteProcessorMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} + +// Request message for the enable processor method. +message EnableProcessorRequest { + // Required. The processor resource name to be enabled. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// Response message for the enable processor method. +// Intentionally empty proto for adding fields in future. +message EnableProcessorResponse { + +} + +// The long running operation metadata for enable processor method. +message EnableProcessorMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} + +// Request message for the disable processor method. +message DisableProcessorRequest { + // Required. The processor resource name to be disabled. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// Response message for the disable processor method. +// Intentionally empty proto for adding fields in future. +message DisableProcessorResponse { + +} + +// The long running operation metadata for disable processor method. +message DisableProcessorMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} + +// Request message for the set default processor version method. +message SetDefaultProcessorVersionRequest { + // Required. The resource name of the [Processor][google.cloud.documentai.v1.Processor] to change default version. + string processor = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; + + // Required. The resource name of child [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] to use as default. + // Format: + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` + string default_processor_version = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Response message for set default processor version method. +message SetDefaultProcessorVersionResponse { + +} + +// The long running operation metadata for set default processor version +// method. +message SetDefaultProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for review document method. +message ReviewDocumentRequest { + // The priority level of the human review task. + enum Priority { + // The default priority level. + DEFAULT = 0; + + // The urgent priority level. The labeling manager should allocate labeler + // resource to the urgent task queue to respect this priority level. + URGENT = 1; + } + + // The document payload. + oneof source { + // An inline document proto. + Document inline_document = 4; + } + + // Required. The resource name of the HumanReviewConfig that the document will be + // reviewed with. + string human_review_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/HumanReviewConfig" + } + ]; + + // Whether the validation should be performed on the ad-hoc review request. + bool enable_schema_validation = 3; + + // The priority of the human review task. + Priority priority = 5; + + // The document schema of the human review task. + DocumentSchema document_schema = 6; +} + +// Response message for review document method. +message ReviewDocumentResponse { + // Possible states of the review operation. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // The review operation is rejected by the reviewer. + REJECTED = 1; + + // The review operation is succeeded. + SUCCEEDED = 2; + } + + // The Cloud Storage uri for the human reviewed document if the review is + // succeeded. + string gcs_destination = 1; + + // The state of the review operation. + State state = 2; + + // The reason why the review is rejected by reviewer. + string rejection_reason = 3; +} + +// The long running operation metadata for review document method. +message ReviewDocumentOperationMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; + + // The Crowd Compute question ID. + string question_id = 6; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_schema.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_schema.proto new file mode 100644 index 00000000000..ceb25a1d69a --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_schema.proto @@ -0,0 +1,141 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.documentai.v1; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiDocumentSchema"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// The schema defines the output of the processed document by a processor. +message DocumentSchema { + // EntityType is the wrapper of a label of the corresponding model with + // detailed attributes and limitations for entity-based processors. Multiple + // types can also compose a dependency tree to represent nested types. + message EntityType { + // Defines the a list of enum values. + message EnumValues { + // The individual values that this enum values type can include. + repeated string values = 1; + } + + // Defines properties that can be part of the entity type. + message Property { + // Types of occurrences of the entity type in the document. Note: this + // represents the number of instances of an entity types, not number of + // mentions of a given entity instance. + enum OccurrenceType { + // Unspecified occurrence type. + OCCURRENCE_TYPE_UNSPECIFIED = 0; + + // There will be zero or one instance of this entity type. + OPTIONAL_ONCE = 1; + + // The entity type will appear zero or multiple times. + OPTIONAL_MULTIPLE = 2; + + // The entity type will only appear exactly once. + REQUIRED_ONCE = 3; + + // The entity type will appear once or more times. + REQUIRED_MULTIPLE = 4; + } + + // The name of the property. Follows the same guidelines as the + // EntityType name. + string name = 1; + + // A reference to the value type of the property. This type is subject + // to the same conventions as the `Entity.base_types` field. + string value_type = 2; + + // Occurrence type limits the number of instances an entity type appears + // in the document. + OccurrenceType occurrence_type = 3; + } + + oneof value_source { + // If specified, lists all the possible values for this entity. This + // should not be more than a handful of values. If the number of values + // is >10 or could change frequently use the `EntityType.value_ontology` + // field and specify a list of all possible values in a value ontology + // file. + EnumValues enum_values = 14; + } + + // User defined name for the type. + string display_name = 13; + + // Name of the type. It must be unique within the schema file and + // cannot be a 'Common Type'. Besides that we use the following naming + // conventions: + // + // - *use `snake_casing`* + // - name matching is case-insensitive + // - Maximum 64 characters. + // - Must start with a letter. + // - Allowed characters: ASCII letters `[a-z0-9_-]`. (For backward + // compatibility internal infrastructure and tooling can handle any ascii + // character) + // - The `/` is sometimes used to denote a property of a type. For example + // `line_item/amount`. This convention is deprecated, but will still be + // honored for backward compatibility. + string name = 1; + + // The entity type that this type is derived from. For now, one and only + // one should be set. + repeated string base_types = 2; + + // Describing the nested structure, or composition of an entity. + repeated Property properties = 6; + } + + // Metadata for global schema behavior. + message Metadata { + // If true, a `document` entity type can be applied to subdocument ( + // splitting). Otherwise, it can only be applied to the entire document + // (classification). + bool document_splitter = 1; + + // If true, on a given page, there can be multiple `document` annotations + // covering it. + bool document_allow_multiple_labels = 2; + + // If set, all the nested entities must be prefixed with the parents. + bool prefixed_naming_on_properties = 6; + + // If set, we will skip the naming format validation in the schema. So the + // string values in `DocumentSchema.EntityType.name` and + // `DocumentSchema.EntityType.Property.name` will not be checked. + bool skip_naming_validation = 7; + } + + // Display name to show to users. + string display_name = 1; + + // Description of the schema. + string description = 2; + + // Entity types of the schema. + repeated EntityType entity_types = 3; + + // Metadata of the schema. + Metadata metadata = 4; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/geometry.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/geometry.proto new file mode 100644 index 00000000000..7471ef01247 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/geometry.proto @@ -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 +// +// 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.documentai.v1; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// A vertex represents a 2D point in the image. +// NOTE: the vertex coordinates are in the same scale as the original image. +message Vertex { + // X coordinate. + int32 x = 1; + + // Y coordinate (starts from the top of the image). + int32 y = 2; +} + +// A vertex represents a 2D point in the image. +// NOTE: the normalized vertex coordinates are relative to the original image +// and range from 0 to 1. +message NormalizedVertex { + // X coordinate. + float x = 1; + + // Y coordinate (starts from the top of the image). + float y = 2; +} + +// A bounding polygon for the detected image annotation. +message BoundingPoly { + // The bounding polygon vertices. + repeated Vertex vertices = 1; + + // The bounding polygon normalized vertices. + repeated NormalizedVertex normalized_vertices = 2; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/operation_metadata.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/operation_metadata.proto new file mode 100644 index 00000000000..5698b0a4f3c --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/operation_metadata.proto @@ -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 +// +// 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.documentai.v1; + +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "OperationMetadataProto"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// The common metadata for long running operations. +message CommonOperationMetadata { + // State of the longrunning operation. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // Operation is still running. + RUNNING = 1; + + // Operation is being cancelled. + CANCELLING = 2; + + // Operation succeeded. + SUCCEEDED = 3; + + // Operation failed. + FAILED = 4; + + // Operation is cancelled. + CANCELLED = 5; + } + + // The state of the operation. + State state = 1; + + // A message providing more details about the current state of processing. + string state_message = 2; + + // A related resource to this operation. + string resource = 5; + + // The creation time of the operation. + google.protobuf.Timestamp create_time = 3; + + // The last update time of the operation. + google.protobuf.Timestamp update_time = 4; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor.proto new file mode 100644 index 00000000000..3ffe6927df9 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor.proto @@ -0,0 +1,189 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.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.documentai.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/documentai/v1/document_schema.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProcessor"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// A processor version is an implementation of a processor. Each processor +// can have multiple versions, pre-trained by Google internally or up-trained +// by the customer. At a time, a processor can only have one default version +// version. So the processor's behavior (when processing documents) is defined +// by a default version +message ProcessorVersion { + option (google.api.resource) = { + type: "documentai.googleapis.com/ProcessorVersion" + pattern: "projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}" + }; + + // Information about the upcoming deprecation of this processor version. + message DeprecationInfo { + // The time at which this processor version will be deprecated. + google.protobuf.Timestamp deprecation_time = 1; + + // If set, the processor version that will be used as a replacement. + string replacement_processor_version = 2 [(google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + }]; + } + + // The possible states of the processor version. + enum State { + // The processor version is in an unspecified state. + STATE_UNSPECIFIED = 0; + + // The processor version is deployed and can be used for processing. + DEPLOYED = 1; + + // The processor version is being deployed. + DEPLOYING = 2; + + // The processor version is not deployed and cannot be used for processing. + UNDEPLOYED = 3; + + // The processor version is being undeployed. + UNDEPLOYING = 4; + + // The processor version is being created. + CREATING = 5; + + // The processor version is being deleted. + DELETING = 6; + + // The processor version failed and is in an indeterminate state. + FAILED = 7; + } + + // The resource name of the processor version. + // Format: + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}` + string name = 1; + + // The display name of the processor version. + string display_name = 2; + + // The schema of the processor version. Describes the output. + DocumentSchema document_schema = 12; + + // The state of the processor version. + State state = 6; + + // The time the processor version was created. + google.protobuf.Timestamp create_time = 7; + + // The KMS key name used for encryption. + string kms_key_name = 9; + + // The KMS key version with which data is encrypted. + string kms_key_version_name = 10; + + // Denotes that this ProcessorVersion is managed by google. + bool google_managed = 11; + + // If set, information about the eventual deprecation of this version. + DeprecationInfo deprecation_info = 13; +} + +// The first-class citizen for Document AI. Each processor defines how to +// extract structural information from a document. +message Processor { + option (google.api.resource) = { + type: "documentai.googleapis.com/Processor" + pattern: "projects/{project}/locations/{location}/processors/{processor}" + }; + + // The possible states of the processor. + enum State { + // The processor is in an unspecified state. + STATE_UNSPECIFIED = 0; + + // The processor is enabled, i.e., has an enabled version which can + // currently serve processing requests and all the feature dependencies have + // been successfully initialized. + ENABLED = 1; + + // The processor is disabled. + DISABLED = 2; + + // The processor is being enabled, will become `ENABLED` if successful. + ENABLING = 3; + + // The processor is being disabled, will become `DISABLED` if successful. + DISABLING = 4; + + // The processor is being created, will become either `ENABLED` (for + // successful creation) or `FAILED` (for failed ones). + // Once a processor is in this state, it can then be used for document + // processing, but the feature dependencies of the processor might not be + // fully created yet. + CREATING = 5; + + // The processor failed during creation or initialization of feature + // dependencies. The user should delete the processor and recreate one as + // all the functionalities of the processor are disabled. + FAILED = 6; + + // The processor is being deleted, will be removed if successful. + DELETING = 7; + } + + // Output only. Immutable. The resource name of the processor. + // Format: `projects/{project}/locations/{location}/processors/{processor}` + string name = 1 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. + // To get a list of processors types, see + // [FetchProcessorTypes][google.cloud.documentai.v1.DocumentProcessorService.FetchProcessorTypes]. + string type = 2; + + // The display name of the processor. + string display_name = 3; + + // Output only. The state of the processor. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The default processor version. + string default_processor_version = 9 [(google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + }]; + + // Output only. Immutable. The http endpoint that can be called to invoke processing. + string process_endpoint = 6 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.field_behavior) = IMMUTABLE + ]; + + // The time the processor was created. + google.protobuf.Timestamp create_time = 7; + + // The KMS key used for encryption/decryption in CMEK scenarios. + // See https://cloud.google.com/security-key-management. + string kms_key_name = 8; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor_type.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor_type.proto new file mode 100644 index 00000000000..2c9ee923051 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor_type.proto @@ -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 +// +// 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.documentai.v1; + +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProcessorType"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// A processor type is responsible for performing a certain document +// understanding task on a certain type of document. +message ProcessorType { + option (google.api.resource) = { + type: "documentai.googleapis.com/ProcessorType" + pattern: "projects/{project}/locations/{location}/processorTypes/{processor_type}" + }; + + // The location information about where the processor is available. + message LocationInfo { + // The location id, currently must be one of [us, eu]. + string location_id = 1; + } + + // The resource name of the processor type. + // Format: `projects/{project}/processorTypes/{processor_type}` + string name = 1; + + // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. + string type = 2; + + // The processor category, used by UI to group processor types. + string category = 3; + + // The locations in which this processor is available. + repeated LocationInfo available_locations = 4; + + // Whether the processor type allows creation. If true, users can create a + // processor of this processor type. Otherwise, users need to request access. + bool allow_creation = 6; + + // Launch stage of the processor type + google.api.LaunchStage launch_stage = 8; +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.create_document_link.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.create_document_link.js new file mode 100644 index 00000000000..d04c5515e32 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.create_document_link.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, documentLink) { + // [START contentwarehouse_v1_generated_DocumentLinkService_CreateDocumentLink_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Parent of the document-link to be created. + * parent of document-link should be a document. + * Format: + * projects/{project_number}/locations/{location}/documents/{source_document_id}. + */ + // const parent = 'abc123' + /** + * Required. Document links associated with the source documents (source_document_id). + */ + // const documentLink = {} + /** + * The meta information collected about the document creator, used to enforce + * access control for the service. + */ + // const requestMetadata = {} + + // Imports the Contentwarehouse library + const {DocumentLinkServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentLinkServiceClient(); + + async function callCreateDocumentLink() { + // Construct request + const request = { + parent, + documentLink, + }; + + // Run request + const response = await contentwarehouseClient.createDocumentLink(request); + console.log(response); + } + + callCreateDocumentLink(); + // [END contentwarehouse_v1_generated_DocumentLinkService_CreateDocumentLink_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.delete_document_link.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.delete_document_link.js new file mode 100644 index 00000000000..f068f8a50e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.delete_document_link.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 contentwarehouse_v1_generated_DocumentLinkService_DeleteDocumentLink_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 document-link to be deleted. + * Format: + * projects/{project_number}/locations/{location}/documents/{source_document_id}/documentLinks/{document_link_id}. + */ + // const name = 'abc123' + /** + * The meta information collected about the document creator, used to enforce + * access control for the service. + */ + // const requestMetadata = {} + + // Imports the Contentwarehouse library + const {DocumentLinkServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentLinkServiceClient(); + + async function callDeleteDocumentLink() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await contentwarehouseClient.deleteDocumentLink(request); + console.log(response); + } + + callDeleteDocumentLink(); + // [END contentwarehouse_v1_generated_DocumentLinkService_DeleteDocumentLink_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_sources.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_sources.js new file mode 100644 index 00000000000..8796f413cdc --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_sources.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(parent) { + // [START contentwarehouse_v1_generated_DocumentLinkService_ListLinkedSources_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 document, for which all source links are returned. + * Format: + * projects/{project_number}/locations/{location}/documents/{source_document_id}. + */ + // const parent = 'abc123' + /** + * The maximum number of document-links to return. The service may return + * fewer than this value. + * If unspecified, at most 50 document-links will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + */ + // const pageSize = 1234 + /** + * A page token, received from a previous `ListLinkedSources` call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to `ListLinkedSources` + * must match the call that provided the page token. + */ + // const pageToken = 'abc123' + /** + * The meta information collected about the document creator, used to enforce + * access control for the service. + */ + // const requestMetadata = {} + + // Imports the Contentwarehouse library + const {DocumentLinkServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentLinkServiceClient(); + + async function callListLinkedSources() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await contentwarehouseClient.listLinkedSourcesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListLinkedSources(); + // [END contentwarehouse_v1_generated_DocumentLinkService_ListLinkedSources_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_targets.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_targets.js new file mode 100644 index 00000000000..f15e3276594 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_targets.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(parent) { + // [START contentwarehouse_v1_generated_DocumentLinkService_ListLinkedTargets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 document, for which all target links are returned. + * Format: + * projects/{project_number}/locations/{location}/documents/{target_document_id}. + */ + // const parent = 'abc123' + /** + * The meta information collected about the document creator, used to enforce + * access control for the service. + */ + // const requestMetadata = {} + + // Imports the Contentwarehouse library + const {DocumentLinkServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentLinkServiceClient(); + + async function callListLinkedTargets() { + // Construct request + const request = { + parent, + }; + + // Run request + const response = await contentwarehouseClient.listLinkedTargets(request); + console.log(response); + } + + callListLinkedTargets(); + // [END contentwarehouse_v1_generated_DocumentLinkService_ListLinkedTargets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.create_document_schema.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.create_document_schema.js new file mode 100644 index 00000000000..c91a34faf6e --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.create_document_schema.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(parent, documentSchema) { + // [START contentwarehouse_v1_generated_DocumentSchemaService_CreateDocumentSchema_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 name. + */ + // const parent = 'abc123' + /** + * Required. The document schema to create. + */ + // const documentSchema = {} + + // Imports the Contentwarehouse library + const {DocumentSchemaServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentSchemaServiceClient(); + + async function callCreateDocumentSchema() { + // Construct request + const request = { + parent, + documentSchema, + }; + + // Run request + const response = await contentwarehouseClient.createDocumentSchema(request); + console.log(response); + } + + callCreateDocumentSchema(); + // [END contentwarehouse_v1_generated_DocumentSchemaService_CreateDocumentSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.delete_document_schema.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.delete_document_schema.js new file mode 100644 index 00000000000..f85067dd155 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.delete_document_schema.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(name) { + // [START contentwarehouse_v1_generated_DocumentSchemaService_DeleteDocumentSchema_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 document schema to delete. + */ + // const name = 'abc123' + + // Imports the Contentwarehouse library + const {DocumentSchemaServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentSchemaServiceClient(); + + async function callDeleteDocumentSchema() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await contentwarehouseClient.deleteDocumentSchema(request); + console.log(response); + } + + callDeleteDocumentSchema(); + // [END contentwarehouse_v1_generated_DocumentSchemaService_DeleteDocumentSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.get_document_schema.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.get_document_schema.js new file mode 100644 index 00000000000..005eb89783e --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.get_document_schema.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(name) { + // [START contentwarehouse_v1_generated_DocumentSchemaService_GetDocumentSchema_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 document schema to retrieve. + */ + // const name = 'abc123' + + // Imports the Contentwarehouse library + const {DocumentSchemaServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentSchemaServiceClient(); + + async function callGetDocumentSchema() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await contentwarehouseClient.getDocumentSchema(request); + console.log(response); + } + + callGetDocumentSchema(); + // [END contentwarehouse_v1_generated_DocumentSchemaService_GetDocumentSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.list_document_schemas.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.list_document_schemas.js new file mode 100644 index 00000000000..5bff35fb80a --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.list_document_schemas.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(parent) { + // [START contentwarehouse_v1_generated_DocumentSchemaService_ListDocumentSchemas_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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, which owns this collection of document schemas. + * Format: projects/{project_number}/locations/{location}. + */ + // const parent = 'abc123' + /** + * The maximum number of document schemas to return. The service may return + * fewer than this value. + * If unspecified, at most 50 document schemas will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + */ + // const pageSize = 1234 + /** + * A page token, received from a previous `ListDocumentSchemas` call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to `ListDocumentSchemas` + * must match the call that provided the page token. + */ + // const pageToken = 'abc123' + + // Imports the Contentwarehouse library + const {DocumentSchemaServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentSchemaServiceClient(); + + async function callListDocumentSchemas() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await contentwarehouseClient.listDocumentSchemasAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListDocumentSchemas(); + // [END contentwarehouse_v1_generated_DocumentSchemaService_ListDocumentSchemas_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.update_document_schema.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.update_document_schema.js new file mode 100644 index 00000000000..89fe9e123cb --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.update_document_schema.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, documentSchema) { + // [START contentwarehouse_v1_generated_DocumentSchemaService_UpdateDocumentSchema_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 document schema to update. + * Format: + * projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. + */ + // const name = 'abc123' + /** + * Required. The document schema to update with. + */ + // const documentSchema = {} + + // Imports the Contentwarehouse library + const {DocumentSchemaServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentSchemaServiceClient(); + + async function callUpdateDocumentSchema() { + // Construct request + const request = { + name, + documentSchema, + }; + + // Run request + const response = await contentwarehouseClient.updateDocumentSchema(request); + console.log(response); + } + + callUpdateDocumentSchema(); + // [END contentwarehouse_v1_generated_DocumentSchemaService_UpdateDocumentSchema_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.create_document.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.create_document.js new file mode 100644 index 00000000000..35fe66612ea --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.create_document.js @@ -0,0 +1,89 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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, document) { + // [START contentwarehouse_v1_generated_DocumentService_CreateDocument_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent name. + * Format: projects/{project_number}/locations/{location}. + */ + // const parent = 'abc123' + /** + * Required. The document to create. + */ + // const document = {} + /** + * The meta information collected about the end user, used to enforce access + * control for the service. + */ + // const requestMetadata = {} + /** + * Default document policy during creation. Conditions defined in the policy + * will be ignored. + */ + // const policy = {} + /** + * Request Option for processing Cloud AI Document in CW Document. + */ + // const cloudAiDocumentOption = {} + /** + * Field mask for creating Document fields. If mask path is empty, + * it means all fields are masked. + * For the `FieldMask` definition, + * see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + */ + // const createMask = {} + + // Imports the Contentwarehouse library + const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentServiceClient(); + + async function callCreateDocument() { + // Construct request + const request = { + parent, + document, + }; + + // Run request + const response = await contentwarehouseClient.createDocument(request); + console.log(response); + } + + callCreateDocument(); + // [END contentwarehouse_v1_generated_DocumentService_CreateDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.delete_document.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.delete_document.js new file mode 100644 index 00000000000..6df73e989bd --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.delete_document.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(name) { + // [START contentwarehouse_v1_generated_DocumentService_DeleteDocument_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the document to delete. + * Format: + * projects/{project_number}/locations/{location}/documents/{document_id} + * or + * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. + */ + // const name = 'abc123' + /** + * The meta information collected about the end user, used to enforce access + * control for the service. + */ + // const requestMetadata = {} + + // Imports the Contentwarehouse library + const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentServiceClient(); + + async function callDeleteDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await contentwarehouseClient.deleteDocument(request); + console.log(response); + } + + callDeleteDocument(); + // [END contentwarehouse_v1_generated_DocumentService_DeleteDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.fetch_acl.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.fetch_acl.js new file mode 100644 index 00000000000..78658a78264 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.fetch_acl.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(resource) { + // [START contentwarehouse_v1_generated_DocumentService_FetchAcl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. REQUIRED: The resource for which the policy is being requested. + * Format for document: + * projects/{project_number}/locations/{location}/documents/{document_id}. + * Format for project: projects/{project_number}. + */ + // const resource = 'abc123' + /** + * The meta information collected about the end user, used to enforce access + * control for the service. + */ + // const requestMetadata = {} + /** + * For Get Project ACL only. Authorization check for end user will be ignored + * when project_owner=true. + */ + // const projectOwner = true + + // Imports the Contentwarehouse library + const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentServiceClient(); + + async function callFetchAcl() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await contentwarehouseClient.fetchAcl(request); + console.log(response); + } + + callFetchAcl(); + // [END contentwarehouse_v1_generated_DocumentService_FetchAcl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.get_document.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.get_document.js new file mode 100644 index 00000000000..02c64981e05 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.get_document.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(name) { + // [START contentwarehouse_v1_generated_DocumentService_GetDocument_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the document to retrieve. + * Format: + * projects/{project_number}/locations/{location}/documents/{document_id} or + * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. + */ + // const name = 'abc123' + /** + * The meta information collected about the end user, used to enforce access + * control for the service. + */ + // const requestMetadata = {} + + // Imports the Contentwarehouse library + const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentServiceClient(); + + async function callGetDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await contentwarehouseClient.getDocument(request); + console.log(response); + } + + callGetDocument(); + // [END contentwarehouse_v1_generated_DocumentService_GetDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.search_documents.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.search_documents.js new file mode 100644 index 00000000000..b98b2b52310 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.search_documents.js @@ -0,0 +1,151 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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 contentwarehouse_v1_generated_DocumentService_SearchDocuments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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, which owns this collection of documents. + * Format: projects/{project_number}/locations/{location}. + */ + // const parent = 'abc123' + /** + * The meta information collected about the end user, used to enforce access + * control and improve the search quality of the service. + */ + // const requestMetadata = {} + /** + * Query used to search against documents (keyword, filters, etc.). + */ + // const documentQuery = {} + /** + * An integer that specifies the current offset (that is, starting result + * location, amongst the documents deemed by the API as relevant) in search + * results. This field is only considered if page_token google.cloud.contentwarehouse.v1.SearchDocumentsRequest.page_token is unset. + * The maximum allowed value is 5000. Otherwise an error is thrown. + * For example, 0 means to return results starting from the first matching + * document, and 10 means to return from the 11th document. This can be used + * for pagination, (for example, pageSize = 10 and offset = 10 means to return + * from the second page). + */ + // const offset = 1234 + /** + * A limit on the number of documents returned in the search results. + * Increasing this value above the default value of 10 can increase search + * response time. The value can be between 1 and 100. + */ + // const pageSize = 1234 + /** + * The token specifying the current offset within search results. + * See SearchDocumentsResponse.next_page_token google.cloud.contentwarehouse.v1.SearchDocumentsResponse.next_page_token for an explanation of how + * to obtain the next set of query results. + */ + // const pageToken = 'abc123' + /** + * The criteria determining how search results are sorted. For non-empty + * query, default is `"relevance desc"`. For empty query, default is + * `"upload_date desc"`. + * Supported options are: + * * `"relevance desc"`: By relevance descending, as determined by the API + * algorithms. + * * `"upload_date desc"`: By upload date descending. + * * `"upload_date"`: By upload date ascending. + * * `"update_date desc"`: By last updated date descending. + * * `"update_date"`: By last updated date ascending. + */ + // const orderBy = 'abc123' + /** + * An expression specifying a histogram request against matching + * documents. Expression syntax is an aggregation function call with + * histogram facets and other options. + * The following aggregation functions are supported: + * * `count(string_histogram_facet)`: Count the number of matching entities + * for each distinct attribute value. + * Data types: + * * Histogram facet (aka filterable properties): Facet names with format + * <schema id>.<facet>. Facets will have the + * format of: `[a-zA-Z][a-zA-Z0-9_:/-.]`. If the facet is a child + * facet, then the parent hierarchy needs to be specified separated by + * dots in the prefix after the schema id. Thus, the format for a multi- + * level facet is: <schema id>.<parent facet name>. + * <child facet name>. Example: + * schema123.root_parent_facet.middle_facet.child_facet + * * DocumentSchemaId: (with no schema id prefix) to get + * histograms for each document type (returns the schema id path, e.g. + * projects/12345/locations/us-west/documentSchemas/abc123). + * Example expression: + * * Document type counts: + * count('DocumentSchemaId') + * * For schema id, abc123, get the counts for MORTGAGE_TYPE: + * count('abc123.MORTGAGE_TYPE') + */ + // const histogramQueries = 1234 + /** + * Optional. Controls if the search document request requires the return of a total size + * of matched documents. See SearchDocumentsResponse.total_size google.cloud.contentwarehouse.v1.SearchDocumentsResponse.total_size. + * Enabling this flag may adversely impact performance. Hint: If this is + * used with pagination, set this flag on the initial query but set this + * to false on subsequent page calls (keep the total count locally). + * Defaults to false. + */ + // const requireTotalSize = true + /** + * Experimental, do not use. + * The limit on the number of documents returned for the question-answering + * feature. To enable the question-answering feature, set + * DocumentQuery.is_nl_query to true. + */ + // const qaSizeLimit = 1234 + + // Imports the Contentwarehouse library + const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentServiceClient(); + + async function callSearchDocuments() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await contentwarehouseClient.searchDocumentsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchDocuments(); + // [END contentwarehouse_v1_generated_DocumentService_SearchDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.set_acl.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.set_acl.js new file mode 100644 index 00000000000..1f7ab4b8157 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.set_acl.js @@ -0,0 +1,80 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource, policy) { + // [START contentwarehouse_v1_generated_DocumentService_SetAcl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. REQUIRED: The resource for which the policy is being requested. + * Format for document: + * projects/{project_number}/locations/{location}/documents/{document_id}. + * Format for project: projects/{project_number}. + */ + // const resource = 'abc123' + /** + * Required. REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. + */ + // const policy = {} + /** + * The meta information collected about the end user, used to enforce access + * control for the service. + */ + // const requestMetadata = {} + /** + * For Set Project ACL only. Authorization check for end user will be ignored + * when project_owner=true. + */ + // const projectOwner = true + + // Imports the Contentwarehouse library + const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentServiceClient(); + + async function callSetAcl() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await contentwarehouseClient.setAcl(request); + console.log(response); + } + + callSetAcl(); + // [END contentwarehouse_v1_generated_DocumentService_SetAcl_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.update_document.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.update_document.js new file mode 100644 index 00000000000..cecb7def88f --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.update_document.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(name, document) { + // [START contentwarehouse_v1_generated_DocumentService_UpdateDocument_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the document to update. + * Format: + * projects/{project_number}/locations/{location}/documents/{document_id} + * or + * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. + */ + // const name = 'abc123' + /** + * Required. The document to update. + */ + // const document = {} + /** + * The meta information collected about the end user, used to enforce access + * control for the service. + */ + // const requestMetadata = {} + /** + * Request Option for processing Cloud AI Document in CW Document. + */ + // const cloudAiDocumentOption = {} + /** + * Options for the update operation. + */ + // const updateOptions = {} + + // Imports the Contentwarehouse library + const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new DocumentServiceClient(); + + async function callUpdateDocument() { + // Construct request + const request = { + name, + document, + }; + + // Run request + const response = await contentwarehouseClient.updateDocument(request); + console.log(response); + } + + callUpdateDocument(); + // [END contentwarehouse_v1_generated_DocumentService_UpdateDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.create_rule_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.create_rule_set.js new file mode 100644 index 00000000000..367e9de519a --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.create_rule_set.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, ruleSet) { + // [START contentwarehouse_v1_generated_RuleSetService_CreateRuleSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 name. + * Format: projects/{project_number}/locations/{location}. + */ + // const parent = 'abc123' + /** + * Required. The rule set to create. + */ + // const ruleSet = {} + + // Imports the Contentwarehouse library + const {RuleSetServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new RuleSetServiceClient(); + + async function callCreateRuleSet() { + // Construct request + const request = { + parent, + ruleSet, + }; + + // Run request + const response = await contentwarehouseClient.createRuleSet(request); + console.log(response); + } + + callCreateRuleSet(); + // [END contentwarehouse_v1_generated_RuleSetService_CreateRuleSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.delete_rule_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.delete_rule_set.js new file mode 100644 index 00000000000..eb9996fd5c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.delete_rule_set.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 contentwarehouse_v1_generated_RuleSetService_DeleteRuleSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 rule set to delete. + * Format: + * projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. + */ + // const name = 'abc123' + + // Imports the Contentwarehouse library + const {RuleSetServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new RuleSetServiceClient(); + + async function callDeleteRuleSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await contentwarehouseClient.deleteRuleSet(request); + console.log(response); + } + + callDeleteRuleSet(); + // [END contentwarehouse_v1_generated_RuleSetService_DeleteRuleSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.get_rule_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.get_rule_set.js new file mode 100644 index 00000000000..1b3b38f738c --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.get_rule_set.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 contentwarehouse_v1_generated_RuleSetService_GetRuleSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 rule set to retrieve. + * Format: + * projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. + */ + // const name = 'abc123' + + // Imports the Contentwarehouse library + const {RuleSetServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new RuleSetServiceClient(); + + async function callGetRuleSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await contentwarehouseClient.getRuleSet(request); + console.log(response); + } + + callGetRuleSet(); + // [END contentwarehouse_v1_generated_RuleSetService_GetRuleSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.list_rule_sets.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.list_rule_sets.js new file mode 100644 index 00000000000..24ceab8ca14 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.list_rule_sets.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(parent) { + // [START contentwarehouse_v1_generated_RuleSetService_ListRuleSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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, which owns this collection of document. + * Format: projects/{project_number}/locations/{location}. + */ + // const parent = 'abc123' + /** + * The maximum number of rule sets to return. The service may return + * fewer than this value. + * If unspecified, at most 50 rule sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + */ + // const pageSize = 1234 + /** + * A page token, received from a previous `ListRuleSets` call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to `ListRuleSets` + * must match the call that provided the page token. + */ + // const pageToken = 'abc123' + + // Imports the Contentwarehouse library + const {RuleSetServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new RuleSetServiceClient(); + + async function callListRuleSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await contentwarehouseClient.listRuleSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListRuleSets(); + // [END contentwarehouse_v1_generated_RuleSetService_ListRuleSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.update_rule_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.update_rule_set.js new file mode 100644 index 00000000000..359577ae72a --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.update_rule_set.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, ruleSet) { + // [START contentwarehouse_v1_generated_RuleSetService_UpdateRuleSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 rule set to update. + * Format: + * projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. + */ + // const name = 'abc123' + /** + * Required. The rule set to update. + */ + // const ruleSet = {} + + // Imports the Contentwarehouse library + const {RuleSetServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new RuleSetServiceClient(); + + async function callUpdateRuleSet() { + // Construct request + const request = { + name, + ruleSet, + }; + + // Run request + const response = await contentwarehouseClient.updateRuleSet(request); + console.log(response); + } + + callUpdateRuleSet(); + // [END contentwarehouse_v1_generated_RuleSetService_UpdateRuleSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/snippet_metadata.google.cloud.contentwarehouse.v1.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/snippet_metadata.google.cloud.contentwarehouse.v1.json new file mode 100644 index 00000000000..ccbf22678d4 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/snippet_metadata.google.cloud.contentwarehouse.v1.json @@ -0,0 +1,1231 @@ +{ + "clientLibrary": { + "name": "nodejs-contentwarehouse", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.contentwarehouse.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "contentwarehouse_v1_generated_DocumentLinkService_ListLinkedTargets_async", + "title": "DocumentLinkService listLinkedTargets Sample", + "origin": "API_DEFINITION", + "description": " Return all target document-links from the document.", + "canonical": true, + "file": "document_link_service.list_linked_targets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListLinkedTargets", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.ListLinkedTargets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.ListLinkedTargetsResponse", + "client": { + "shortName": "DocumentLinkServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkServiceClient" + }, + "method": { + "shortName": "ListLinkedTargets", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.ListLinkedTargets", + "service": { + "shortName": "DocumentLinkService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentLinkService_ListLinkedSources_async", + "title": "DocumentLinkService listLinkedSources Sample", + "origin": "API_DEFINITION", + "description": " Return all source document-links from the document.", + "canonical": true, + "file": "document_link_service.list_linked_sources.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 76, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListLinkedSources", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.ListLinkedSources", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.ListLinkedSourcesResponse", + "client": { + "shortName": "DocumentLinkServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkServiceClient" + }, + "method": { + "shortName": "ListLinkedSources", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.ListLinkedSources", + "service": { + "shortName": "DocumentLinkService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentLinkService_CreateDocumentLink_async", + "title": "DocumentLinkService createDocumentLink Sample", + "origin": "API_DEFINITION", + "description": " Create a link between a source document and a target document.", + "canonical": true, + "file": "document_link_service.create_document_link.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDocumentLink", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.CreateDocumentLink", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "document_link", + "type": ".google.cloud.contentwarehouse.v1.DocumentLink" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.DocumentLink", + "client": { + "shortName": "DocumentLinkServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkServiceClient" + }, + "method": { + "shortName": "CreateDocumentLink", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.CreateDocumentLink", + "service": { + "shortName": "DocumentLinkService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentLinkService_DeleteDocumentLink_async", + "title": "DocumentLinkService deleteDocumentLink Sample", + "origin": "API_DEFINITION", + "description": " Remove the link between the source and target documents.", + "canonical": true, + "file": "document_link_service.delete_document_link.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDocumentLink", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.DeleteDocumentLink", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "DocumentLinkServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkServiceClient" + }, + "method": { + "shortName": "DeleteDocumentLink", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.DeleteDocumentLink", + "service": { + "shortName": "DocumentLinkService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentSchemaService_CreateDocumentSchema_async", + "title": "DocumentLinkService createDocumentSchema Sample", + "origin": "API_DEFINITION", + "description": " Creates a document schema.", + "canonical": true, + "file": "document_schema_service.create_document_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDocumentSchema", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.CreateDocumentSchema", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "document_schema", + "type": ".google.cloud.contentwarehouse.v1.DocumentSchema" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.DocumentSchema", + "client": { + "shortName": "DocumentSchemaServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaServiceClient" + }, + "method": { + "shortName": "CreateDocumentSchema", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.CreateDocumentSchema", + "service": { + "shortName": "DocumentSchemaService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentSchemaService_UpdateDocumentSchema_async", + "title": "DocumentLinkService updateDocumentSchema Sample", + "origin": "API_DEFINITION", + "description": " Updates a Document Schema. Returns INVALID_ARGUMENT if the name of the Document Schema is non-empty and does not equal the existing name. Supports only appending new properties, adding new ENUM possible values, and updating the [EnumTypeOptions.validation_check_disabled][google.cloud.contentwarehouse.v1.EnumTypeOptions.validation_check_disabled] flag for ENUM possible values. Updating existing properties will result into INVALID_ARGUMENT.", + "canonical": true, + "file": "document_schema_service.update_document_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDocumentSchema", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.UpdateDocumentSchema", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "document_schema", + "type": ".google.cloud.contentwarehouse.v1.DocumentSchema" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.DocumentSchema", + "client": { + "shortName": "DocumentSchemaServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaServiceClient" + }, + "method": { + "shortName": "UpdateDocumentSchema", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.UpdateDocumentSchema", + "service": { + "shortName": "DocumentSchemaService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentSchemaService_GetDocumentSchema_async", + "title": "DocumentLinkService getDocumentSchema Sample", + "origin": "API_DEFINITION", + "description": " Gets a document schema. Returns NOT_FOUND if the document schema does not exist.", + "canonical": true, + "file": "document_schema_service.get_document_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDocumentSchema", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.GetDocumentSchema", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.DocumentSchema", + "client": { + "shortName": "DocumentSchemaServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaServiceClient" + }, + "method": { + "shortName": "GetDocumentSchema", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.GetDocumentSchema", + "service": { + "shortName": "DocumentSchemaService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentSchemaService_DeleteDocumentSchema_async", + "title": "DocumentLinkService deleteDocumentSchema Sample", + "origin": "API_DEFINITION", + "description": " Deletes a document schema. Returns NOT_FOUND if the document schema does not exist. Returns BAD_REQUEST if the document schema has documents depending on it.", + "canonical": true, + "file": "document_schema_service.delete_document_schema.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDocumentSchema", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.DeleteDocumentSchema", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "DocumentSchemaServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaServiceClient" + }, + "method": { + "shortName": "DeleteDocumentSchema", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.DeleteDocumentSchema", + "service": { + "shortName": "DocumentSchemaService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentSchemaService_ListDocumentSchemas_async", + "title": "DocumentLinkService listDocumentSchemas Sample", + "origin": "API_DEFINITION", + "description": " Lists document schemas.", + "canonical": true, + "file": "document_schema_service.list_document_schemas.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDocumentSchemas", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.ListDocumentSchemas", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.ListDocumentSchemasResponse", + "client": { + "shortName": "DocumentSchemaServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaServiceClient" + }, + "method": { + "shortName": "ListDocumentSchemas", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.ListDocumentSchemas", + "service": { + "shortName": "DocumentSchemaService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentService_CreateDocument_async", + "title": "DocumentLinkService createDocument Sample", + "origin": "API_DEFINITION", + "description": " Creates a document.", + "canonical": true, + "file": "document_service.create_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 81, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDocument", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.CreateDocument", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "document", + "type": ".google.cloud.contentwarehouse.v1.Document" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "cloud_ai_document_option", + "type": ".google.cloud.contentwarehouse.v1.CloudAIDocumentOption" + }, + { + "name": "create_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.CreateDocumentResponse", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" + }, + "method": { + "shortName": "CreateDocument", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.CreateDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentService_GetDocument_async", + "title": "DocumentLinkService getDocument Sample", + "origin": "API_DEFINITION", + "description": " Gets a document. Returns NOT_FOUND if the document does not exist.", + "canonical": true, + "file": "document_service.get_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDocument", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.GetDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.Document", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" + }, + "method": { + "shortName": "GetDocument", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.GetDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentService_UpdateDocument_async", + "title": "DocumentLinkService updateDocument Sample", + "origin": "API_DEFINITION", + "description": " Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing name.", + "canonical": true, + "file": "document_service.update_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDocument", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.UpdateDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "document", + "type": ".google.cloud.contentwarehouse.v1.Document" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + }, + { + "name": "cloud_ai_document_option", + "type": ".google.cloud.contentwarehouse.v1.CloudAIDocumentOption" + }, + { + "name": "update_options", + "type": ".google.cloud.contentwarehouse.v1.UpdateOptions" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.UpdateDocumentResponse", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" + }, + "method": { + "shortName": "UpdateDocument", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.UpdateDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentService_DeleteDocument_async", + "title": "DocumentLinkService deleteDocument Sample", + "origin": "API_DEFINITION", + "description": " Deletes a document. Returns NOT_FOUND if the document does not exist.", + "canonical": true, + "file": "document_service.delete_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDocument", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.DeleteDocument", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" + }, + "method": { + "shortName": "DeleteDocument", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.DeleteDocument", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentService_SearchDocuments_async", + "title": "DocumentLinkService searchDocuments Sample", + "origin": "API_DEFINITION", + "description": " Searches for documents using provided [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. This call only returns documents that the caller has permission to search against.", + "canonical": true, + "file": "document_service.search_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 143, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchDocuments", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.SearchDocuments", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + }, + { + "name": "document_query", + "type": ".google.cloud.contentwarehouse.v1.DocumentQuery" + }, + { + "name": "offset", + "type": "TYPE_INT32" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "order_by", + "type": "TYPE_STRING" + }, + { + "name": "histogram_queries", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "require_total_size", + "type": "TYPE_BOOL" + }, + { + "name": "qa_size_limit", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.SearchDocumentsResponse", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" + }, + "method": { + "shortName": "SearchDocuments", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.SearchDocuments", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentService_FetchAcl_async", + "title": "DocumentLinkService fetchAcl Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. Returns NOT_FOUND error if the resource does not exist. Returns an empty policy if the resource exists but does not have a policy set.", + "canonical": true, + "file": "document_service.fetch_acl.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "FetchAcl", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.FetchAcl", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + }, + { + "name": "project_owner", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.FetchAclResponse", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" + }, + "method": { + "shortName": "FetchAcl", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.FetchAcl", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_DocumentService_SetAcl_async", + "title": "DocumentLinkService setAcl Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy for a resource. Replaces any existing policy.", + "canonical": true, + "file": "document_service.set_acl.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetAcl", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.SetAcl", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "request_metadata", + "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" + }, + { + "name": "project_owner", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.SetAclResponse", + "client": { + "shortName": "DocumentServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" + }, + "method": { + "shortName": "SetAcl", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService.SetAcl", + "service": { + "shortName": "DocumentService", + "fullName": "google.cloud.contentwarehouse.v1.DocumentService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_RuleSetService_CreateRuleSet_async", + "title": "DocumentLinkService createRuleSet Sample", + "origin": "API_DEFINITION", + "description": " Creates a ruleset.", + "canonical": true, + "file": "rule_set_service.create_rule_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateRuleSet", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.CreateRuleSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "rule_set", + "type": ".google.cloud.contentwarehouse.v1.RuleSet" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.RuleSet", + "client": { + "shortName": "RuleSetServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetServiceClient" + }, + "method": { + "shortName": "CreateRuleSet", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.CreateRuleSet", + "service": { + "shortName": "RuleSetService", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_RuleSetService_GetRuleSet_async", + "title": "DocumentLinkService getRuleSet Sample", + "origin": "API_DEFINITION", + "description": " Gets a ruleset. Returns NOT_FOUND if the ruleset does not exist.", + "canonical": true, + "file": "rule_set_service.get_rule_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetRuleSet", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.GetRuleSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.RuleSet", + "client": { + "shortName": "RuleSetServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetServiceClient" + }, + "method": { + "shortName": "GetRuleSet", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.GetRuleSet", + "service": { + "shortName": "RuleSetService", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_RuleSetService_UpdateRuleSet_async", + "title": "DocumentLinkService updateRuleSet Sample", + "origin": "API_DEFINITION", + "description": " Updates a ruleset. Returns INVALID_ARGUMENT if the name of the ruleset is non-empty and does not equal the existing name.", + "canonical": true, + "file": "rule_set_service.update_rule_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateRuleSet", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.UpdateRuleSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "rule_set", + "type": ".google.cloud.contentwarehouse.v1.RuleSet" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.RuleSet", + "client": { + "shortName": "RuleSetServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetServiceClient" + }, + "method": { + "shortName": "UpdateRuleSet", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.UpdateRuleSet", + "service": { + "shortName": "RuleSetService", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_RuleSetService_DeleteRuleSet_async", + "title": "DocumentLinkService deleteRuleSet Sample", + "origin": "API_DEFINITION", + "description": " Deletes a ruleset. Returns NOT_FOUND if the document does not exist.", + "canonical": true, + "file": "rule_set_service.delete_rule_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteRuleSet", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.DeleteRuleSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "RuleSetServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetServiceClient" + }, + "method": { + "shortName": "DeleteRuleSet", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.DeleteRuleSet", + "service": { + "shortName": "RuleSetService", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_RuleSetService_ListRuleSets_async", + "title": "DocumentLinkService listRuleSets Sample", + "origin": "API_DEFINITION", + "description": " Lists rulesets.", + "canonical": true, + "file": "rule_set_service.list_rule_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListRuleSets", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.ListRuleSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.ListRuleSetsResponse", + "client": { + "shortName": "RuleSetServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetServiceClient" + }, + "method": { + "shortName": "ListRuleSets", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.ListRuleSets", + "service": { + "shortName": "RuleSetService", + "fullName": "google.cloud.contentwarehouse.v1.RuleSetService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_SynonymSetService_CreateSynonymSet_async", + "title": "DocumentLinkService createSynonymSet Sample", + "origin": "API_DEFINITION", + "description": " Creates a SynonymSet for a single context. Throws an ALREADY_EXISTS exception if a synonymset already exists for the context.", + "canonical": true, + "file": "synonym_set_service.create_synonym_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSynonymSet", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.CreateSynonymSet", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "synonym_set", + "type": ".google.cloud.contentwarehouse.v1.SynonymSet" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.SynonymSet", + "client": { + "shortName": "SynonymSetServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetServiceClient" + }, + "method": { + "shortName": "CreateSynonymSet", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.CreateSynonymSet", + "service": { + "shortName": "SynonymSetService", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_SynonymSetService_GetSynonymSet_async", + "title": "DocumentLinkService getSynonymSet Sample", + "origin": "API_DEFINITION", + "description": " Gets a SynonymSet for a particular context. Throws a NOT_FOUND exception if the Synonymset does not exist", + "canonical": true, + "file": "synonym_set_service.get_synonym_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetSynonymSet", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.GetSynonymSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.SynonymSet", + "client": { + "shortName": "SynonymSetServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetServiceClient" + }, + "method": { + "shortName": "GetSynonymSet", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.GetSynonymSet", + "service": { + "shortName": "SynonymSetService", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_SynonymSetService_UpdateSynonymSet_async", + "title": "DocumentLinkService updateSynonymSet Sample", + "origin": "API_DEFINITION", + "description": " Remove the existing SynonymSet for the context and replaces it with a new one. Throws a NOT_FOUND exception if the SynonymSet is not found.", + "canonical": true, + "file": "synonym_set_service.update_synonym_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateSynonymSet", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.UpdateSynonymSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "synonym_set", + "type": ".google.cloud.contentwarehouse.v1.SynonymSet" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.SynonymSet", + "client": { + "shortName": "SynonymSetServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetServiceClient" + }, + "method": { + "shortName": "UpdateSynonymSet", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.UpdateSynonymSet", + "service": { + "shortName": "SynonymSetService", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_SynonymSetService_DeleteSynonymSet_async", + "title": "DocumentLinkService deleteSynonymSet Sample", + "origin": "API_DEFINITION", + "description": " Deletes a SynonymSet for a given context. Throws a NOT_FOUND exception if the SynonymSet is not found.", + "canonical": true, + "file": "synonym_set_service.delete_synonym_set.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteSynonymSet", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.DeleteSynonymSet", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "SynonymSetServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetServiceClient" + }, + "method": { + "shortName": "DeleteSynonymSet", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.DeleteSynonymSet", + "service": { + "shortName": "SynonymSetService", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService" + } + } + } + }, + { + "regionTag": "contentwarehouse_v1_generated_SynonymSetService_ListSynonymSets_async", + "title": "DocumentLinkService listSynonymSets Sample", + "origin": "API_DEFINITION", + "description": " Returns all SynonymSets (for all contexts) for the specified location.", + "canonical": true, + "file": "synonym_set_service.list_synonym_sets.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListSynonymSets", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.ListSynonymSets", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.contentwarehouse.v1.ListSynonymSetsResponse", + "client": { + "shortName": "SynonymSetServiceClient", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetServiceClient" + }, + "method": { + "shortName": "ListSynonymSets", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.ListSynonymSets", + "service": { + "shortName": "SynonymSetService", + "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.create_synonym_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.create_synonym_set.js new file mode 100644 index 00000000000..c6be0ae02c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.create_synonym_set.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, synonymSet) { + // [START contentwarehouse_v1_generated_SynonymSetService_CreateSynonymSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 name. + * Format: projects/{project_number}/locations/{location}. + */ + // const parent = 'abc123' + /** + * Required. The synonymSet to be created for a context + */ + // const synonymSet = {} + + // Imports the Contentwarehouse library + const {SynonymSetServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new SynonymSetServiceClient(); + + async function callCreateSynonymSet() { + // Construct request + const request = { + parent, + synonymSet, + }; + + // Run request + const response = await contentwarehouseClient.createSynonymSet(request); + console.log(response); + } + + callCreateSynonymSet(); + // [END contentwarehouse_v1_generated_SynonymSetService_CreateSynonymSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.delete_synonym_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.delete_synonym_set.js new file mode 100644 index 00000000000..82a7bb6f94e --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.delete_synonym_set.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 contentwarehouse_v1_generated_SynonymSetService_DeleteSynonymSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 synonymSet to delete + * Format: + * projects/{project_number}/locations/{location}/synonymSets/{context}. + */ + // const name = 'abc123' + + // Imports the Contentwarehouse library + const {SynonymSetServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new SynonymSetServiceClient(); + + async function callDeleteSynonymSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await contentwarehouseClient.deleteSynonymSet(request); + console.log(response); + } + + callDeleteSynonymSet(); + // [END contentwarehouse_v1_generated_SynonymSetService_DeleteSynonymSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.get_synonym_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.get_synonym_set.js new file mode 100644 index 00000000000..9f3367f25fe --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.get_synonym_set.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 contentwarehouse_v1_generated_SynonymSetService_GetSynonymSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 synonymSet to retrieve + * Format: + * projects/{project_number}/locations/{location}/synonymSets/{context}. + */ + // const name = 'abc123' + + // Imports the Contentwarehouse library + const {SynonymSetServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new SynonymSetServiceClient(); + + async function callGetSynonymSet() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await contentwarehouseClient.getSynonymSet(request); + console.log(response); + } + + callGetSynonymSet(); + // [END contentwarehouse_v1_generated_SynonymSetService_GetSynonymSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.list_synonym_sets.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.list_synonym_sets.js new file mode 100644 index 00000000000..0f9fff5df07 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.list_synonym_sets.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(parent) { + // [START contentwarehouse_v1_generated_SynonymSetService_ListSynonymSets_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 name. + * Format: projects/{project_number}/locations/{location}. + */ + // const parent = 'abc123' + /** + * The maximum number of synonymSets to return. The service may return + * fewer than this value. + * If unspecified, at most 50 rule sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + */ + // const pageSize = 1234 + /** + * A page token, received from a previous `ListSynonymSets` call. + * Provide this to retrieve the subsequent page. + * When paginating, all other parameters provided to `ListSynonymSets` + * must match the call that provided the page token. + */ + // const pageToken = 'abc123' + + // Imports the Contentwarehouse library + const {SynonymSetServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new SynonymSetServiceClient(); + + async function callListSynonymSets() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await contentwarehouseClient.listSynonymSetsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListSynonymSets(); + // [END contentwarehouse_v1_generated_SynonymSetService_ListSynonymSets_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.update_synonym_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.update_synonym_set.js new file mode 100644 index 00000000000..6df8717dcf7 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.update_synonym_set.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, synonymSet) { + // [START contentwarehouse_v1_generated_SynonymSetService_UpdateSynonymSet_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will 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 synonymSet to update + * Format: + * projects/{project_number}/locations/{location}/synonymSets/{context}. + */ + // const name = 'abc123' + /** + * Required. The synonymSet to be updated for the customer + */ + // const synonymSet = {} + + // Imports the Contentwarehouse library + const {SynonymSetServiceClient} = require('@google-cloud/contentwarehouse').v1; + + // Instantiates a client + const contentwarehouseClient = new SynonymSetServiceClient(); + + async function callUpdateSynonymSet() { + // Construct request + const request = { + name, + synonymSet, + }; + + // Run request + const response = await contentwarehouseClient.updateSynonymSet(request); + console.log(response); + } + + callUpdateSynonymSet(); + // [END contentwarehouse_v1_generated_SynonymSetService_UpdateSynonymSet_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/index.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/index.ts new file mode 100644 index 00000000000..6bba2b51edc --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/index.ts @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const DocumentLinkServiceClient = v1.DocumentLinkServiceClient; +type DocumentLinkServiceClient = v1.DocumentLinkServiceClient; +const DocumentSchemaServiceClient = v1.DocumentSchemaServiceClient; +type DocumentSchemaServiceClient = v1.DocumentSchemaServiceClient; +const DocumentServiceClient = v1.DocumentServiceClient; +type DocumentServiceClient = v1.DocumentServiceClient; +const RuleSetServiceClient = v1.RuleSetServiceClient; +type RuleSetServiceClient = v1.RuleSetServiceClient; +const SynonymSetServiceClient = v1.SynonymSetServiceClient; +type SynonymSetServiceClient = v1.SynonymSetServiceClient; +export {v1, DocumentLinkServiceClient, DocumentSchemaServiceClient, DocumentServiceClient, RuleSetServiceClient, SynonymSetServiceClient}; +export default {v1, DocumentLinkServiceClient, DocumentSchemaServiceClient, DocumentServiceClient, RuleSetServiceClient, SynonymSetServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client.ts new file mode 100644 index 00000000000..035693b0614 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client.ts @@ -0,0 +1,1095 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/document_link_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './document_link_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * This service lets you manage document-links. + * Document-Links are treated as sub-resources under source documents. + * @class + * @memberof v1 + */ +export class DocumentLinkServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + documentLinkServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DocumentLinkServiceClient. + * + * @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 DocumentLinkServiceClient({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 DocumentLinkServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + documentLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}' + ), + documentSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documentSchemas/{document_schema}' + ), + projectLocationDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/{document}' + ), + projectLocationDocumentsReferenceIdPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/referenceId/{reference_id}' + ), + ruleSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/ruleSets/{rule_set}' + ), + synonymSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/synonymSets/{context}' + ), + }; + + // 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 = { + listLinkedSources: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documentLinks') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.contentwarehouse.v1.DocumentLinkService', 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.documentLinkServiceStub) { + return this.documentLinkServiceStub; + } + + // Put together the "service stub" for + // google.cloud.contentwarehouse.v1.DocumentLinkService. + this.documentLinkServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.contentwarehouse.v1.DocumentLinkService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.contentwarehouse.v1.DocumentLinkService, + 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 documentLinkServiceStubMethods = + ['listLinkedTargets', 'listLinkedSources', 'createDocumentLink', 'deleteDocumentLink']; + for (const methodName of documentLinkServiceStubMethods) { + const callPromise = this.documentLinkServiceStub.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.documentLinkServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'contentwarehouse.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 'contentwarehouse.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 -- + // ------------------- +/** + * Return all target document-links from the document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the document, for which all target links are returned. + * Format: + * projects/{project_number}/locations/{location}/documents/{target_document_id}. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the document creator, used to enforce + * access control for the service. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ListLinkedTargetsResponse]{@link google.cloud.contentwarehouse.v1.ListLinkedTargetsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_link_service.list_linked_targets.js + * region_tag:contentwarehouse_v1_generated_DocumentLinkService_ListLinkedTargets_async + */ + listLinkedTargets( + request?: protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|undefined, {}|undefined + ]>; + listLinkedTargets( + request: protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|null|undefined, + {}|null|undefined>): void; + listLinkedTargets( + request: protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|null|undefined, + {}|null|undefined>): void; + listLinkedTargets( + request?: protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, + protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listLinkedTargets(request, options, callback); + } +/** + * Create a link between a source document and a target document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent of the document-link to be created. + * parent of document-link should be a document. + * Format: + * projects/{project_number}/locations/{location}/documents/{source_document_id}. + * @param {google.cloud.contentwarehouse.v1.DocumentLink} request.documentLink + * Required. Document links associated with the source documents (source_document_id). + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the document creator, used to enforce + * access control for the service. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DocumentLink]{@link google.cloud.contentwarehouse.v1.DocumentLink}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_link_service.create_document_link.js + * region_tag:contentwarehouse_v1_generated_DocumentLinkService_CreateDocumentLink_async + */ + createDocumentLink( + request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentLink, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|undefined, {}|undefined + ]>; + createDocumentLink( + request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentLink, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|null|undefined, + {}|null|undefined>): void; + createDocumentLink( + request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentLink, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|null|undefined, + {}|null|undefined>): void; + createDocumentLink( + request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentLink, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentLink, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentLink, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createDocumentLink(request, options, callback); + } +/** + * Remove the link between the source and target documents. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the document-link to be deleted. + * Format: + * projects/{project_number}/locations/{location}/documents/{source_document_id}/documentLinks/{document_link_id}. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the document creator, used to enforce + * access control for the service. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_link_service.delete_document_link.js + * region_tag:contentwarehouse_v1_generated_DocumentLinkService_DeleteDocumentLink_async + */ + deleteDocumentLink( + request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|undefined, {}|undefined + ]>; + deleteDocumentLink( + request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|null|undefined, + {}|null|undefined>): void; + deleteDocumentLink( + request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|null|undefined, + {}|null|undefined>): void; + deleteDocumentLink( + request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteDocumentLink(request, options, callback); + } + + /** + * Return all source document-links from the document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the document, for which all source links are returned. + * Format: + * projects/{project_number}/locations/{location}/documents/{source_document_id}. + * @param {number} request.pageSize + * The maximum number of document-links to return. The service may return + * fewer than this value. + * + * If unspecified, at most 50 document-links will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListLinkedSources` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListLinkedSources` + * must match the call that provided the page token. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the document creator, used to enforce + * access control for the service. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [DocumentLink]{@link google.cloud.contentwarehouse.v1.DocumentLink}. + * 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 `listLinkedSourcesAsync()` + * 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. + */ + listLinkedSources( + request?: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentLink[], + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest|null, + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse + ]>; + listLinkedSources( + request: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IDocumentLink>): void; + listLinkedSources( + request: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, + callback: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IDocumentLink>): void; + listLinkedSources( + request?: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IDocumentLink>, + callback?: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IDocumentLink>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentLink[], + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest|null, + protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listLinkedSources(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 name of the document, for which all source links are returned. + * Format: + * projects/{project_number}/locations/{location}/documents/{source_document_id}. + * @param {number} request.pageSize + * The maximum number of document-links to return. The service may return + * fewer than this value. + * + * If unspecified, at most 50 document-links will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListLinkedSources` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListLinkedSources` + * must match the call that provided the page token. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the document creator, used to enforce + * access control for the service. + * @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 [DocumentLink]{@link google.cloud.contentwarehouse.v1.DocumentLink} 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 `listLinkedSourcesAsync()` + * 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. + */ + listLinkedSourcesStream( + request?: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, + 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['listLinkedSources']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listLinkedSources.createStream( + this.innerApiCalls.listLinkedSources as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listLinkedSources`, 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 name of the document, for which all source links are returned. + * Format: + * projects/{project_number}/locations/{location}/documents/{source_document_id}. + * @param {number} request.pageSize + * The maximum number of document-links to return. The service may return + * fewer than this value. + * + * If unspecified, at most 50 document-links will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListLinkedSources` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListLinkedSources` + * must match the call that provided the page token. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the document creator, used to enforce + * access control for the service. + * @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 + * [DocumentLink]{@link google.cloud.contentwarehouse.v1.DocumentLink}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/document_link_service.list_linked_sources.js + * region_tag:contentwarehouse_v1_generated_DocumentLinkService_ListLinkedSources_async + */ + listLinkedSourcesAsync( + request?: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, + 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['listLinkedSources']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listLinkedSources.asyncIterate( + this.innerApiCalls['listLinkedSources'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified documentLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document + * @param {string} document_link + * @returns {string} Resource name string. + */ + documentLinkPath(project:string,location:string,document:string,documentLink:string) { + return this.pathTemplates.documentLinkPathTemplate.render({ + project: project, + location: location, + document: document, + document_link: documentLink, + }); + } + + /** + * Parse the project from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).project; + } + + /** + * Parse the location from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).location; + } + + /** + * Parse the document from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document; + } + + /** + * Parse the document_link from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the document_link. + */ + matchDocumentLinkFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document_link; + } + + /** + * Return a fully-qualified documentSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document_schema + * @returns {string} Resource name string. + */ + documentSchemaPath(project:string,location:string,documentSchema:string) { + return this.pathTemplates.documentSchemaPathTemplate.render({ + project: project, + location: location, + document_schema: documentSchema, + }); + } + + /** + * Parse the project from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).project; + } + + /** + * Parse the location from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).location; + } + + /** + * Parse the document_schema from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the document_schema. + */ + matchDocumentSchemaFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).document_schema; + } + + /** + * Return a fully-qualified projectLocationDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDocumentPath(project:string,location:string,document:string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.render({ + project: project, + location: location, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).location; + } + + /** + * Parse the document from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDocumentsReferenceId resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} reference_id + * @returns {string} Resource name string. + */ + projectLocationDocumentsReferenceIdPath(project:string,location:string,referenceId:string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render({ + project: project, + location: location, + reference_id: referenceId, + }); + } + + /** + * Parse the project from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).project; + } + + /** + * Parse the location from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).location; + } + + /** + * Parse the reference_id from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the reference_id. + */ + matchReferenceIdFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).reference_id; + } + + /** + * Return a fully-qualified ruleSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} rule_set + * @returns {string} Resource name string. + */ + ruleSetPath(project:string,location:string,ruleSet:string) { + return this.pathTemplates.ruleSetPathTemplate.render({ + project: project, + location: location, + rule_set: ruleSet, + }); + } + + /** + * Parse the project from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).project; + } + + /** + * Parse the location from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).location; + } + + /** + * Parse the rule_set from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the rule_set. + */ + matchRuleSetFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).rule_set; + } + + /** + * Return a fully-qualified synonymSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} context + * @returns {string} Resource name string. + */ + synonymSetPath(project:string,location:string,context:string) { + return this.pathTemplates.synonymSetPathTemplate.render({ + project: project, + location: location, + context: context, + }); + } + + /** + * Parse the project from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).project; + } + + /** + * Parse the location from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).location; + } + + /** + * Parse the context from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the context. + */ + matchContextFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).context; + } + + /** + * 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.documentLinkServiceStub && !this._terminated) { + return this.documentLinkServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client_config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client_config.json new file mode 100644 index 00000000000..50fc7af4f4a --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.contentwarehouse.v1.DocumentLinkService": { + "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": { + "ListLinkedTargets": { + "timeout_millis": 180000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListLinkedSources": { + "timeout_millis": 180000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateDocumentLink": { + "timeout_millis": 180000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteDocumentLink": { + "timeout_millis": 180000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_proto_list.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_proto_list.json new file mode 100644 index 00000000000..e85ca71c0c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/common.proto", + "../../protos/google/cloud/contentwarehouse/v1/document.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_link_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_schema.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_schema_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/filters.proto", + "../../protos/google/cloud/contentwarehouse/v1/histogram.proto", + "../../protos/google/cloud/contentwarehouse/v1/rule_engine.proto", + "../../protos/google/cloud/contentwarehouse/v1/ruleset_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto", + "../../protos/google/cloud/documentai/v1/barcode.proto", + "../../protos/google/cloud/documentai/v1/document.proto", + "../../protos/google/cloud/documentai/v1/geometry.proto" +] diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client.ts new file mode 100644 index 00000000000..80264b81bea --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client.ts @@ -0,0 +1,1185 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/document_schema_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './document_schema_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * This service lets you manage document schema. + * @class + * @memberof v1 + */ +export class DocumentSchemaServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + documentSchemaServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DocumentSchemaServiceClient. + * + * @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 DocumentSchemaServiceClient({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 DocumentSchemaServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + documentLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}' + ), + documentSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documentSchemas/{document_schema}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectLocationDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/{document}' + ), + projectLocationDocumentsReferenceIdPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/referenceId/{reference_id}' + ), + ruleSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/ruleSets/{rule_set}' + ), + synonymSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/synonymSets/{context}' + ), + }; + + // 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 = { + listDocumentSchemas: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documentSchemas') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.contentwarehouse.v1.DocumentSchemaService', 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.documentSchemaServiceStub) { + return this.documentSchemaServiceStub; + } + + // Put together the "service stub" for + // google.cloud.contentwarehouse.v1.DocumentSchemaService. + this.documentSchemaServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.contentwarehouse.v1.DocumentSchemaService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.contentwarehouse.v1.DocumentSchemaService, + 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 documentSchemaServiceStubMethods = + ['createDocumentSchema', 'updateDocumentSchema', 'getDocumentSchema', 'deleteDocumentSchema', 'listDocumentSchemas']; + for (const methodName of documentSchemaServiceStubMethods) { + const callPromise = this.documentSchemaServiceStub.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.documentSchemaServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'contentwarehouse.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 'contentwarehouse.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 document schema. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent name. + * @param {google.cloud.contentwarehouse.v1.DocumentSchema} request.documentSchema + * Required. The document schema to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_schema_service.create_document_schema.js + * region_tag:contentwarehouse_v1_generated_DocumentSchemaService_CreateDocumentSchema_async + */ + createDocumentSchema( + request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|undefined, {}|undefined + ]>; + createDocumentSchema( + request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|null|undefined, + {}|null|undefined>): void; + createDocumentSchema( + request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|null|undefined, + {}|null|undefined>): void; + createDocumentSchema( + request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createDocumentSchema(request, options, callback); + } +/** + * Updates a Document Schema. Returns INVALID_ARGUMENT if the name of the + * Document Schema is non-empty and does not equal the existing name. + * Supports only appending new properties, adding new ENUM possible values, + * and updating the {@link google.cloud.contentwarehouse.v1.EnumTypeOptions.validation_check_disabled|EnumTypeOptions.validation_check_disabled} flag for + * ENUM possible values. Updating existing properties will result into + * INVALID_ARGUMENT. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the document schema to update. + * Format: + * projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. + * @param {google.cloud.contentwarehouse.v1.DocumentSchema} request.documentSchema + * Required. The document schema to update with. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_schema_service.update_document_schema.js + * region_tag:contentwarehouse_v1_generated_DocumentSchemaService_UpdateDocumentSchema_async + */ + updateDocumentSchema( + request?: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|undefined, {}|undefined + ]>; + updateDocumentSchema( + request: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|null|undefined, + {}|null|undefined>): void; + updateDocumentSchema( + request: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|null|undefined, + {}|null|undefined>): void; + updateDocumentSchema( + request?: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.updateDocumentSchema(request, options, callback); + } +/** + * Gets a document schema. Returns NOT_FOUND if the document schema does not + * exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the document schema to retrieve. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_schema_service.get_document_schema.js + * region_tag:contentwarehouse_v1_generated_DocumentSchemaService_GetDocumentSchema_async + */ + getDocumentSchema( + request?: protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|undefined, {}|undefined + ]>; + getDocumentSchema( + request: protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|null|undefined, + {}|null|undefined>): void; + getDocumentSchema( + request: protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|null|undefined, + {}|null|undefined>): void; + getDocumentSchema( + request?: protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentSchema, + protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getDocumentSchema(request, options, callback); + } +/** + * Deletes a document schema. Returns NOT_FOUND if the document schema does + * not exist. Returns BAD_REQUEST if the document schema has documents + * depending on it. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the document schema to delete. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_schema_service.delete_document_schema.js + * region_tag:contentwarehouse_v1_generated_DocumentSchemaService_DeleteDocumentSchema_async + */ + deleteDocumentSchema( + request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|undefined, {}|undefined + ]>; + deleteDocumentSchema( + request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|null|undefined, + {}|null|undefined>): void; + deleteDocumentSchema( + request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|null|undefined, + {}|null|undefined>): void; + deleteDocumentSchema( + request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteDocumentSchema(request, options, callback); + } + + /** + * Lists document schemas. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of document schemas. + * Format: projects/{project_number}/locations/{location}. + * @param {number} request.pageSize + * The maximum number of document schemas to return. The service may return + * fewer than this value. + * If unspecified, at most 50 document schemas will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListDocumentSchemas` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListDocumentSchemas` + * must match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema}. + * 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 `listDocumentSchemasAsync()` + * 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. + */ + listDocumentSchemas( + request?: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentSchema[], + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest|null, + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse + ]>; + listDocumentSchemas( + request: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IDocumentSchema>): void; + listDocumentSchemas( + request: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, + callback: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IDocumentSchema>): void; + listDocumentSchemas( + request?: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IDocumentSchema>, + callback?: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IDocumentSchema>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocumentSchema[], + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest|null, + protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listDocumentSchemas(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, which owns this collection of document schemas. + * Format: projects/{project_number}/locations/{location}. + * @param {number} request.pageSize + * The maximum number of document schemas to return. The service may return + * fewer than this value. + * If unspecified, at most 50 document schemas will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListDocumentSchemas` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListDocumentSchemas` + * must match the call that provided the page token. + * @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 [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema} 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 `listDocumentSchemasAsync()` + * 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. + */ + listDocumentSchemasStream( + request?: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, + 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['listDocumentSchemas']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocumentSchemas.createStream( + this.innerApiCalls.listDocumentSchemas as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listDocumentSchemas`, 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, which owns this collection of document schemas. + * Format: projects/{project_number}/locations/{location}. + * @param {number} request.pageSize + * The maximum number of document schemas to return. The service may return + * fewer than this value. + * If unspecified, at most 50 document schemas will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListDocumentSchemas` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListDocumentSchemas` + * must match the call that provided the 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 + * [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/document_schema_service.list_document_schemas.js + * region_tag:contentwarehouse_v1_generated_DocumentSchemaService_ListDocumentSchemas_async + */ + listDocumentSchemasAsync( + request?: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, + 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['listDocumentSchemas']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDocumentSchemas.asyncIterate( + this.innerApiCalls['listDocumentSchemas'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified documentLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document + * @param {string} document_link + * @returns {string} Resource name string. + */ + documentLinkPath(project:string,location:string,document:string,documentLink:string) { + return this.pathTemplates.documentLinkPathTemplate.render({ + project: project, + location: location, + document: document, + document_link: documentLink, + }); + } + + /** + * Parse the project from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).project; + } + + /** + * Parse the location from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).location; + } + + /** + * Parse the document from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document; + } + + /** + * Parse the document_link from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the document_link. + */ + matchDocumentLinkFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document_link; + } + + /** + * Return a fully-qualified documentSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document_schema + * @returns {string} Resource name string. + */ + documentSchemaPath(project:string,location:string,documentSchema:string) { + return this.pathTemplates.documentSchemaPathTemplate.render({ + project: project, + location: location, + document_schema: documentSchema, + }); + } + + /** + * Parse the project from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).project; + } + + /** + * Parse the location from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).location; + } + + /** + * Parse the document_schema from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the document_schema. + */ + matchDocumentSchemaFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).document_schema; + } + + /** + * 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 projectLocationDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDocumentPath(project:string,location:string,document:string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.render({ + project: project, + location: location, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).location; + } + + /** + * Parse the document from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDocumentsReferenceId resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} reference_id + * @returns {string} Resource name string. + */ + projectLocationDocumentsReferenceIdPath(project:string,location:string,referenceId:string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render({ + project: project, + location: location, + reference_id: referenceId, + }); + } + + /** + * Parse the project from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).project; + } + + /** + * Parse the location from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).location; + } + + /** + * Parse the reference_id from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the reference_id. + */ + matchReferenceIdFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).reference_id; + } + + /** + * Return a fully-qualified ruleSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} rule_set + * @returns {string} Resource name string. + */ + ruleSetPath(project:string,location:string,ruleSet:string) { + return this.pathTemplates.ruleSetPathTemplate.render({ + project: project, + location: location, + rule_set: ruleSet, + }); + } + + /** + * Parse the project from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).project; + } + + /** + * Parse the location from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).location; + } + + /** + * Parse the rule_set from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the rule_set. + */ + matchRuleSetFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).rule_set; + } + + /** + * Return a fully-qualified synonymSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} context + * @returns {string} Resource name string. + */ + synonymSetPath(project:string,location:string,context:string) { + return this.pathTemplates.synonymSetPathTemplate.render({ + project: project, + location: location, + context: context, + }); + } + + /** + * Parse the project from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).project; + } + + /** + * Parse the location from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).location; + } + + /** + * Parse the context from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the context. + */ + matchContextFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).context; + } + + /** + * 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.documentSchemaServiceStub && !this._terminated) { + return this.documentSchemaServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client_config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client_config.json new file mode 100644 index 00000000000..80dfa82b9d0 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client_config.json @@ -0,0 +1,63 @@ +{ + "interfaces": { + "google.cloud.contentwarehouse.v1.DocumentSchemaService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateDocumentSchema": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateDocumentSchema": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetDocumentSchema": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "DeleteDocumentSchema": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListDocumentSchemas": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_proto_list.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_proto_list.json new file mode 100644 index 00000000000..e85ca71c0c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/common.proto", + "../../protos/google/cloud/contentwarehouse/v1/document.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_link_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_schema.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_schema_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/filters.proto", + "../../protos/google/cloud/contentwarehouse/v1/histogram.proto", + "../../protos/google/cloud/contentwarehouse/v1/rule_engine.proto", + "../../protos/google/cloud/contentwarehouse/v1/ruleset_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto", + "../../protos/google/cloud/documentai/v1/barcode.proto", + "../../protos/google/cloud/documentai/v1/document.proto", + "../../protos/google/cloud/documentai/v1/geometry.proto" +] diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client.ts new file mode 100644 index 00000000000..bc617cbeebf --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client.ts @@ -0,0 +1,1557 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/document_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './document_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * This service lets you manage document. + * @class + * @memberof v1 + */ +export class DocumentServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + documentServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DocumentServiceClient. + * + * @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 DocumentServiceClient({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 DocumentServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + documentLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}' + ), + documentSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documentSchemas/{document_schema}' + ), + projectLocationDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/{document}' + ), + projectLocationDocumentsReferenceIdPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/referenceId/{reference_id}' + ), + ruleSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/ruleSets/{rule_set}' + ), + synonymSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/synonymSets/{context}' + ), + }; + + // 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 = { + searchDocuments: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'matchingDocuments') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.contentwarehouse.v1.DocumentService', 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.documentServiceStub) { + return this.documentServiceStub; + } + + // Put together the "service stub" for + // google.cloud.contentwarehouse.v1.DocumentService. + this.documentServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.contentwarehouse.v1.DocumentService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.contentwarehouse.v1.DocumentService, + 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 documentServiceStubMethods = + ['createDocument', 'getDocument', 'updateDocument', 'deleteDocument', 'searchDocuments', 'fetchAcl', 'setAcl']; + for (const methodName of documentServiceStubMethods) { + const callPromise = this.documentServiceStub.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.documentServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'contentwarehouse.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 'contentwarehouse.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 document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent name. + * Format: projects/{project_number}/locations/{location}. + * @param {google.cloud.contentwarehouse.v1.Document} request.document + * Required. The document to create. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the end user, used to enforce access + * control for the service. + * @param {google.iam.v1.Policy} request.policy + * Default document policy during creation. Conditions defined in the policy + * will be ignored. + * @param {google.cloud.contentwarehouse.v1.CloudAIDocumentOption} request.cloudAiDocumentOption + * Request Option for processing Cloud AI Document in CW Document. + * @param {google.protobuf.FieldMask} request.createMask + * Field mask for creating Document fields. If mask path is empty, + * it means all fields are masked. + * For the `FieldMask` definition, + * see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CreateDocumentResponse]{@link google.cloud.contentwarehouse.v1.CreateDocumentResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_service.create_document.js + * region_tag:contentwarehouse_v1_generated_DocumentService_CreateDocument_async + */ + createDocument( + request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|undefined, {}|undefined + ]>; + createDocument( + request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): void; + createDocument( + request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): void; + createDocument( + request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createDocument(request, options, callback); + } +/** + * Gets a document. Returns NOT_FOUND if the document does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the document to retrieve. + * Format: + * projects/{project_number}/locations/{location}/documents/{document_id} or + * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the end user, used to enforce access + * control for the service. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Document]{@link google.cloud.contentwarehouse.v1.Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_service.get_document.js + * region_tag:contentwarehouse_v1_generated_DocumentService_GetDocument_async + */ + getDocument( + request?: protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocument, + protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|undefined, {}|undefined + ]>; + getDocument( + request: protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IDocument, + protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): void; + getDocument( + request: protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IDocument, + protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): void; + getDocument( + request?: protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IDocument, + protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IDocument, + protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IDocument, + protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDocument(request, options, callback); + } +/** + * Updates a document. Returns INVALID_ARGUMENT if the name of the document + * is non-empty and does not equal the existing name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the document to update. + * Format: + * projects/{project_number}/locations/{location}/documents/{document_id} + * or + * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. + * @param {google.cloud.contentwarehouse.v1.Document} request.document + * Required. The document to update. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the end user, used to enforce access + * control for the service. + * @param {google.cloud.contentwarehouse.v1.CloudAIDocumentOption} request.cloudAiDocumentOption + * Request Option for processing Cloud AI Document in CW Document. + * @param {google.cloud.contentwarehouse.v1.UpdateOptions} request.updateOptions + * Options for the update operation. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UpdateDocumentResponse]{@link google.cloud.contentwarehouse.v1.UpdateDocumentResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_service.update_document.js + * region_tag:contentwarehouse_v1_generated_DocumentService_UpdateDocument_async + */ + updateDocument( + request?: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|undefined, {}|undefined + ]>; + updateDocument( + request: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): void; + updateDocument( + request: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): void; + updateDocument( + request?: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, + protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateDocument(request, options, callback); + } +/** + * Deletes a document. Returns NOT_FOUND if the document does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the document to delete. + * Format: + * projects/{project_number}/locations/{location}/documents/{document_id} + * or + * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the end user, used to enforce access + * control for the service. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_service.delete_document.js + * region_tag:contentwarehouse_v1_generated_DocumentService_DeleteDocument_async + */ + deleteDocument( + request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|undefined, {}|undefined + ]>; + deleteDocument( + request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): void; + deleteDocument( + request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): void; + deleteDocument( + request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteDocument(request, options, callback); + } +/** + * Gets the access control policy for a resource. Returns NOT_FOUND error if + * the resource does not exist. Returns an empty policy if the resource exists + * but does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * Required. REQUIRED: The resource for which the policy is being requested. + * Format for document: + * projects/{project_number}/locations/{location}/documents/{document_id}. + * Format for project: projects/{project_number}. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the end user, used to enforce access + * control for the service. + * @param {boolean} request.projectOwner + * For Get Project ACL only. Authorization check for end user will be ignored + * when project_owner=true. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [FetchAclResponse]{@link google.cloud.contentwarehouse.v1.FetchAclResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_service.fetch_acl.js + * region_tag:contentwarehouse_v1_generated_DocumentService_FetchAcl_async + */ + fetchAcl( + request?: protos.google.cloud.contentwarehouse.v1.IFetchAclRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, + protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|undefined, {}|undefined + ]>; + fetchAcl( + request: protos.google.cloud.contentwarehouse.v1.IFetchAclRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, + protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|null|undefined, + {}|null|undefined>): void; + fetchAcl( + request: protos.google.cloud.contentwarehouse.v1.IFetchAclRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, + protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|null|undefined, + {}|null|undefined>): void; + fetchAcl( + request?: protos.google.cloud.contentwarehouse.v1.IFetchAclRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, + protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, + protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, + protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.fetchAcl(request, options, callback); + } +/** + * Sets the access control policy for a resource. Replaces any existing + * policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * Required. REQUIRED: The resource for which the policy is being requested. + * Format for document: + * projects/{project_number}/locations/{location}/documents/{document_id}. + * Format for project: projects/{project_number}. + * @param {google.iam.v1.Policy} request.policy + * Required. REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the end user, used to enforce access + * control for the service. + * @param {boolean} request.projectOwner + * For Set Project ACL only. Authorization check for end user will be ignored + * when project_owner=true. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SetAclResponse]{@link google.cloud.contentwarehouse.v1.SetAclResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_service.set_acl.js + * region_tag:contentwarehouse_v1_generated_DocumentService_SetAcl_async + */ + setAcl( + request?: protos.google.cloud.contentwarehouse.v1.ISetAclRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ISetAclResponse, + protos.google.cloud.contentwarehouse.v1.ISetAclRequest|undefined, {}|undefined + ]>; + setAcl( + request: protos.google.cloud.contentwarehouse.v1.ISetAclRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.ISetAclResponse, + protos.google.cloud.contentwarehouse.v1.ISetAclRequest|null|undefined, + {}|null|undefined>): void; + setAcl( + request: protos.google.cloud.contentwarehouse.v1.ISetAclRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.ISetAclResponse, + protos.google.cloud.contentwarehouse.v1.ISetAclRequest|null|undefined, + {}|null|undefined>): void; + setAcl( + request?: protos.google.cloud.contentwarehouse.v1.ISetAclRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.ISetAclResponse, + protos.google.cloud.contentwarehouse.v1.ISetAclRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.ISetAclResponse, + protos.google.cloud.contentwarehouse.v1.ISetAclRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ISetAclResponse, + protos.google.cloud.contentwarehouse.v1.ISetAclRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'resource': request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setAcl(request, options, callback); + } + + /** + * Searches for documents using provided {@link google.cloud.contentwarehouse.v1.SearchDocumentsRequest|SearchDocumentsRequest}. + * This call only returns documents that the caller has permission to search + * against. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of documents. + * Format: projects/{project_number}/locations/{location}. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the end user, used to enforce access + * control and improve the search quality of the service. + * @param {google.cloud.contentwarehouse.v1.DocumentQuery} request.documentQuery + * Query used to search against documents (keyword, filters, etc.). + * @param {number} request.offset + * An integer that specifies the current offset (that is, starting result + * location, amongst the documents deemed by the API as relevant) in search + * results. This field is only considered if {@link google.cloud.contentwarehouse.v1.SearchDocumentsRequest.page_token|page_token} is unset. + * + * The maximum allowed value is 5000. Otherwise an error is thrown. + * + * For example, 0 means to return results starting from the first matching + * document, and 10 means to return from the 11th document. This can be used + * for pagination, (for example, pageSize = 10 and offset = 10 means to return + * from the second page). + * @param {number} request.pageSize + * A limit on the number of documents returned in the search results. + * Increasing this value above the default value of 10 can increase search + * response time. The value can be between 1 and 100. + * @param {string} request.pageToken + * The token specifying the current offset within search results. + * See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.next_page_token|SearchDocumentsResponse.next_page_token} for an explanation of how + * to obtain the next set of query results. + * @param {string} request.orderBy + * The criteria determining how search results are sorted. For non-empty + * query, default is `"relevance desc"`. For empty query, default is + * `"upload_date desc"`. + * + * Supported options are: + * + * * `"relevance desc"`: By relevance descending, as determined by the API + * algorithms. + * * `"upload_date desc"`: By upload date descending. + * * `"upload_date"`: By upload date ascending. + * * `"update_date desc"`: By last updated date descending. + * * `"update_date"`: By last updated date ascending. + * @param {number[]} request.histogramQueries + * An expression specifying a histogram request against matching + * documents. Expression syntax is an aggregation function call with + * histogram facets and other options. + * + * The following aggregation functions are supported: + * + * * `count(string_histogram_facet)`: Count the number of matching entities + * for each distinct attribute value. + * + * Data types: + * + * * Histogram facet (aka filterable properties): Facet names with format + * <schema id>.<facet>. Facets will have the + * format of: `{@link a-zA-Z0-9_:/-.|a-zA-Z}`. If the facet is a child + * facet, then the parent hierarchy needs to be specified separated by + * dots in the prefix after the schema id. Thus, the format for a multi- + * level facet is: <schema id>.<parent facet name>. + * <child facet name>. Example: + * schema123.root_parent_facet.middle_facet.child_facet + * * DocumentSchemaId: (with no schema id prefix) to get + * histograms for each document type (returns the schema id path, e.g. + * projects/12345/locations/us-west/documentSchemas/abc123). + * + * Example expression: + * + * * Document type counts: + * count('DocumentSchemaId') + * + * * For schema id, abc123, get the counts for MORTGAGE_TYPE: + * count('abc123.MORTGAGE_TYPE') + * @param {boolean} request.requireTotalSize + * Optional. Controls if the search document request requires the return of a total size + * of matched documents. See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.total_size|SearchDocumentsResponse.total_size}. + * + * Enabling this flag may adversely impact performance. Hint: If this is + * used with pagination, set this flag on the initial query but set this + * to false on subsequent page calls (keep the total count locally). + * + * Defaults to false. + * @param {number} request.qaSizeLimit + * Experimental, do not use. + * The limit on the number of documents returned for the question-answering + * feature. To enable the question-answering feature, set + * {@link |DocumentQuery].[is_nl_query} to true. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [MatchingDocument]{@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument}. + * 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 `searchDocumentsAsync()` + * 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. + */ + searchDocuments( + request?: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument[], + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest|null, + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse + ]>; + searchDocuments( + request: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument>): void; + searchDocuments( + request: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, + callback: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument>): void; + searchDocuments( + request?: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument>, + callback?: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument[], + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest|null, + protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.searchDocuments(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, which owns this collection of documents. + * Format: projects/{project_number}/locations/{location}. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the end user, used to enforce access + * control and improve the search quality of the service. + * @param {google.cloud.contentwarehouse.v1.DocumentQuery} request.documentQuery + * Query used to search against documents (keyword, filters, etc.). + * @param {number} request.offset + * An integer that specifies the current offset (that is, starting result + * location, amongst the documents deemed by the API as relevant) in search + * results. This field is only considered if {@link google.cloud.contentwarehouse.v1.SearchDocumentsRequest.page_token|page_token} is unset. + * + * The maximum allowed value is 5000. Otherwise an error is thrown. + * + * For example, 0 means to return results starting from the first matching + * document, and 10 means to return from the 11th document. This can be used + * for pagination, (for example, pageSize = 10 and offset = 10 means to return + * from the second page). + * @param {number} request.pageSize + * A limit on the number of documents returned in the search results. + * Increasing this value above the default value of 10 can increase search + * response time. The value can be between 1 and 100. + * @param {string} request.pageToken + * The token specifying the current offset within search results. + * See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.next_page_token|SearchDocumentsResponse.next_page_token} for an explanation of how + * to obtain the next set of query results. + * @param {string} request.orderBy + * The criteria determining how search results are sorted. For non-empty + * query, default is `"relevance desc"`. For empty query, default is + * `"upload_date desc"`. + * + * Supported options are: + * + * * `"relevance desc"`: By relevance descending, as determined by the API + * algorithms. + * * `"upload_date desc"`: By upload date descending. + * * `"upload_date"`: By upload date ascending. + * * `"update_date desc"`: By last updated date descending. + * * `"update_date"`: By last updated date ascending. + * @param {number[]} request.histogramQueries + * An expression specifying a histogram request against matching + * documents. Expression syntax is an aggregation function call with + * histogram facets and other options. + * + * The following aggregation functions are supported: + * + * * `count(string_histogram_facet)`: Count the number of matching entities + * for each distinct attribute value. + * + * Data types: + * + * * Histogram facet (aka filterable properties): Facet names with format + * <schema id>.<facet>. Facets will have the + * format of: `{@link a-zA-Z0-9_:/-.|a-zA-Z}`. If the facet is a child + * facet, then the parent hierarchy needs to be specified separated by + * dots in the prefix after the schema id. Thus, the format for a multi- + * level facet is: <schema id>.<parent facet name>. + * <child facet name>. Example: + * schema123.root_parent_facet.middle_facet.child_facet + * * DocumentSchemaId: (with no schema id prefix) to get + * histograms for each document type (returns the schema id path, e.g. + * projects/12345/locations/us-west/documentSchemas/abc123). + * + * Example expression: + * + * * Document type counts: + * count('DocumentSchemaId') + * + * * For schema id, abc123, get the counts for MORTGAGE_TYPE: + * count('abc123.MORTGAGE_TYPE') + * @param {boolean} request.requireTotalSize + * Optional. Controls if the search document request requires the return of a total size + * of matched documents. See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.total_size|SearchDocumentsResponse.total_size}. + * + * Enabling this flag may adversely impact performance. Hint: If this is + * used with pagination, set this flag on the initial query but set this + * to false on subsequent page calls (keep the total count locally). + * + * Defaults to false. + * @param {number} request.qaSizeLimit + * Experimental, do not use. + * The limit on the number of documents returned for the question-answering + * feature. To enable the question-answering feature, set + * {@link |DocumentQuery].[is_nl_query} to true. + * @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 [MatchingDocument]{@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument} 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 `searchDocumentsAsync()` + * 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. + */ + searchDocumentsStream( + request?: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, + 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['searchDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchDocuments.createStream( + this.innerApiCalls.searchDocuments as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchDocuments`, 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, which owns this collection of documents. + * Format: projects/{project_number}/locations/{location}. + * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata + * The meta information collected about the end user, used to enforce access + * control and improve the search quality of the service. + * @param {google.cloud.contentwarehouse.v1.DocumentQuery} request.documentQuery + * Query used to search against documents (keyword, filters, etc.). + * @param {number} request.offset + * An integer that specifies the current offset (that is, starting result + * location, amongst the documents deemed by the API as relevant) in search + * results. This field is only considered if {@link google.cloud.contentwarehouse.v1.SearchDocumentsRequest.page_token|page_token} is unset. + * + * The maximum allowed value is 5000. Otherwise an error is thrown. + * + * For example, 0 means to return results starting from the first matching + * document, and 10 means to return from the 11th document. This can be used + * for pagination, (for example, pageSize = 10 and offset = 10 means to return + * from the second page). + * @param {number} request.pageSize + * A limit on the number of documents returned in the search results. + * Increasing this value above the default value of 10 can increase search + * response time. The value can be between 1 and 100. + * @param {string} request.pageToken + * The token specifying the current offset within search results. + * See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.next_page_token|SearchDocumentsResponse.next_page_token} for an explanation of how + * to obtain the next set of query results. + * @param {string} request.orderBy + * The criteria determining how search results are sorted. For non-empty + * query, default is `"relevance desc"`. For empty query, default is + * `"upload_date desc"`. + * + * Supported options are: + * + * * `"relevance desc"`: By relevance descending, as determined by the API + * algorithms. + * * `"upload_date desc"`: By upload date descending. + * * `"upload_date"`: By upload date ascending. + * * `"update_date desc"`: By last updated date descending. + * * `"update_date"`: By last updated date ascending. + * @param {number[]} request.histogramQueries + * An expression specifying a histogram request against matching + * documents. Expression syntax is an aggregation function call with + * histogram facets and other options. + * + * The following aggregation functions are supported: + * + * * `count(string_histogram_facet)`: Count the number of matching entities + * for each distinct attribute value. + * + * Data types: + * + * * Histogram facet (aka filterable properties): Facet names with format + * <schema id>.<facet>. Facets will have the + * format of: `{@link a-zA-Z0-9_:/-.|a-zA-Z}`. If the facet is a child + * facet, then the parent hierarchy needs to be specified separated by + * dots in the prefix after the schema id. Thus, the format for a multi- + * level facet is: <schema id>.<parent facet name>. + * <child facet name>. Example: + * schema123.root_parent_facet.middle_facet.child_facet + * * DocumentSchemaId: (with no schema id prefix) to get + * histograms for each document type (returns the schema id path, e.g. + * projects/12345/locations/us-west/documentSchemas/abc123). + * + * Example expression: + * + * * Document type counts: + * count('DocumentSchemaId') + * + * * For schema id, abc123, get the counts for MORTGAGE_TYPE: + * count('abc123.MORTGAGE_TYPE') + * @param {boolean} request.requireTotalSize + * Optional. Controls if the search document request requires the return of a total size + * of matched documents. See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.total_size|SearchDocumentsResponse.total_size}. + * + * Enabling this flag may adversely impact performance. Hint: If this is + * used with pagination, set this flag on the initial query but set this + * to false on subsequent page calls (keep the total count locally). + * + * Defaults to false. + * @param {number} request.qaSizeLimit + * Experimental, do not use. + * The limit on the number of documents returned for the question-answering + * feature. To enable the question-answering feature, set + * {@link |DocumentQuery].[is_nl_query} to true. + * @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 + * [MatchingDocument]{@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/document_service.search_documents.js + * region_tag:contentwarehouse_v1_generated_DocumentService_SearchDocuments_async + */ + searchDocumentsAsync( + request?: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, + 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['searchDocuments']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchDocuments.asyncIterate( + this.innerApiCalls['searchDocuments'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified documentLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document + * @param {string} document_link + * @returns {string} Resource name string. + */ + documentLinkPath(project:string,location:string,document:string,documentLink:string) { + return this.pathTemplates.documentLinkPathTemplate.render({ + project: project, + location: location, + document: document, + document_link: documentLink, + }); + } + + /** + * Parse the project from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).project; + } + + /** + * Parse the location from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).location; + } + + /** + * Parse the document from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document; + } + + /** + * Parse the document_link from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the document_link. + */ + matchDocumentLinkFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document_link; + } + + /** + * Return a fully-qualified documentSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document_schema + * @returns {string} Resource name string. + */ + documentSchemaPath(project:string,location:string,documentSchema:string) { + return this.pathTemplates.documentSchemaPathTemplate.render({ + project: project, + location: location, + document_schema: documentSchema, + }); + } + + /** + * Parse the project from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).project; + } + + /** + * Parse the location from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).location; + } + + /** + * Parse the document_schema from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the document_schema. + */ + matchDocumentSchemaFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).document_schema; + } + + /** + * Return a fully-qualified projectLocationDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDocumentPath(project:string,location:string,document:string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.render({ + project: project, + location: location, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).location; + } + + /** + * Parse the document from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDocumentsReferenceId resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} reference_id + * @returns {string} Resource name string. + */ + projectLocationDocumentsReferenceIdPath(project:string,location:string,referenceId:string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render({ + project: project, + location: location, + reference_id: referenceId, + }); + } + + /** + * Parse the project from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).project; + } + + /** + * Parse the location from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).location; + } + + /** + * Parse the reference_id from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the reference_id. + */ + matchReferenceIdFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).reference_id; + } + + /** + * Return a fully-qualified ruleSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} rule_set + * @returns {string} Resource name string. + */ + ruleSetPath(project:string,location:string,ruleSet:string) { + return this.pathTemplates.ruleSetPathTemplate.render({ + project: project, + location: location, + rule_set: ruleSet, + }); + } + + /** + * Parse the project from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).project; + } + + /** + * Parse the location from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).location; + } + + /** + * Parse the rule_set from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the rule_set. + */ + matchRuleSetFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).rule_set; + } + + /** + * Return a fully-qualified synonymSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} context + * @returns {string} Resource name string. + */ + synonymSetPath(project:string,location:string,context:string) { + return this.pathTemplates.synonymSetPathTemplate.render({ + project: project, + location: location, + context: context, + }); + } + + /** + * Parse the project from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).project; + } + + /** + * Parse the location from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).location; + } + + /** + * Parse the context from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the context. + */ + matchContextFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).context; + } + + /** + * 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.documentServiceStub && !this._terminated) { + return this.documentServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client_config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client_config.json new file mode 100644 index 00000000000..93f35fd6410 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client_config.json @@ -0,0 +1,73 @@ +{ + "interfaces": { + "google.cloud.contentwarehouse.v1.DocumentService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateDocument": { + "timeout_millis": 180000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetDocument": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateDocument": { + "timeout_millis": 180000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteDocument": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SearchDocuments": { + "timeout_millis": 180000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "FetchAcl": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "SetAcl": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_proto_list.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_proto_list.json new file mode 100644 index 00000000000..e85ca71c0c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/common.proto", + "../../protos/google/cloud/contentwarehouse/v1/document.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_link_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_schema.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_schema_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/filters.proto", + "../../protos/google/cloud/contentwarehouse/v1/histogram.proto", + "../../protos/google/cloud/contentwarehouse/v1/rule_engine.proto", + "../../protos/google/cloud/contentwarehouse/v1/ruleset_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto", + "../../protos/google/cloud/documentai/v1/barcode.proto", + "../../protos/google/cloud/documentai/v1/document.proto", + "../../protos/google/cloud/documentai/v1/geometry.proto" +] diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..e15eab1c98f --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/gapic_metadata.json @@ -0,0 +1,359 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.contentwarehouse.v1", + "libraryPackage": "@google-cloud/contentwarehouse", + "services": { + "DocumentLinkService": { + "clients": { + "grpc": { + "libraryClient": "DocumentLinkServiceClient", + "rpcs": { + "ListLinkedTargets": { + "methods": [ + "listLinkedTargets" + ] + }, + "CreateDocumentLink": { + "methods": [ + "createDocumentLink" + ] + }, + "DeleteDocumentLink": { + "methods": [ + "deleteDocumentLink" + ] + }, + "ListLinkedSources": { + "methods": [ + "listLinkedSources", + "listLinkedSourcesStream", + "listLinkedSourcesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentLinkServiceClient", + "rpcs": { + "ListLinkedTargets": { + "methods": [ + "listLinkedTargets" + ] + }, + "CreateDocumentLink": { + "methods": [ + "createDocumentLink" + ] + }, + "DeleteDocumentLink": { + "methods": [ + "deleteDocumentLink" + ] + }, + "ListLinkedSources": { + "methods": [ + "listLinkedSources", + "listLinkedSourcesStream", + "listLinkedSourcesAsync" + ] + } + } + } + } + }, + "DocumentSchemaService": { + "clients": { + "grpc": { + "libraryClient": "DocumentSchemaServiceClient", + "rpcs": { + "CreateDocumentSchema": { + "methods": [ + "createDocumentSchema" + ] + }, + "UpdateDocumentSchema": { + "methods": [ + "updateDocumentSchema" + ] + }, + "GetDocumentSchema": { + "methods": [ + "getDocumentSchema" + ] + }, + "DeleteDocumentSchema": { + "methods": [ + "deleteDocumentSchema" + ] + }, + "ListDocumentSchemas": { + "methods": [ + "listDocumentSchemas", + "listDocumentSchemasStream", + "listDocumentSchemasAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentSchemaServiceClient", + "rpcs": { + "CreateDocumentSchema": { + "methods": [ + "createDocumentSchema" + ] + }, + "UpdateDocumentSchema": { + "methods": [ + "updateDocumentSchema" + ] + }, + "GetDocumentSchema": { + "methods": [ + "getDocumentSchema" + ] + }, + "DeleteDocumentSchema": { + "methods": [ + "deleteDocumentSchema" + ] + }, + "ListDocumentSchemas": { + "methods": [ + "listDocumentSchemas", + "listDocumentSchemasStream", + "listDocumentSchemasAsync" + ] + } + } + } + } + }, + "DocumentService": { + "clients": { + "grpc": { + "libraryClient": "DocumentServiceClient", + "rpcs": { + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "FetchAcl": { + "methods": [ + "fetchAcl" + ] + }, + "SetAcl": { + "methods": [ + "setAcl" + ] + }, + "SearchDocuments": { + "methods": [ + "searchDocuments", + "searchDocumentsStream", + "searchDocumentsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentServiceClient", + "rpcs": { + "CreateDocument": { + "methods": [ + "createDocument" + ] + }, + "GetDocument": { + "methods": [ + "getDocument" + ] + }, + "UpdateDocument": { + "methods": [ + "updateDocument" + ] + }, + "DeleteDocument": { + "methods": [ + "deleteDocument" + ] + }, + "FetchAcl": { + "methods": [ + "fetchAcl" + ] + }, + "SetAcl": { + "methods": [ + "setAcl" + ] + }, + "SearchDocuments": { + "methods": [ + "searchDocuments", + "searchDocumentsStream", + "searchDocumentsAsync" + ] + } + } + } + } + }, + "RuleSetService": { + "clients": { + "grpc": { + "libraryClient": "RuleSetServiceClient", + "rpcs": { + "CreateRuleSet": { + "methods": [ + "createRuleSet" + ] + }, + "GetRuleSet": { + "methods": [ + "getRuleSet" + ] + }, + "UpdateRuleSet": { + "methods": [ + "updateRuleSet" + ] + }, + "DeleteRuleSet": { + "methods": [ + "deleteRuleSet" + ] + }, + "ListRuleSets": { + "methods": [ + "listRuleSets", + "listRuleSetsStream", + "listRuleSetsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "RuleSetServiceClient", + "rpcs": { + "CreateRuleSet": { + "methods": [ + "createRuleSet" + ] + }, + "GetRuleSet": { + "methods": [ + "getRuleSet" + ] + }, + "UpdateRuleSet": { + "methods": [ + "updateRuleSet" + ] + }, + "DeleteRuleSet": { + "methods": [ + "deleteRuleSet" + ] + }, + "ListRuleSets": { + "methods": [ + "listRuleSets", + "listRuleSetsStream", + "listRuleSetsAsync" + ] + } + } + } + } + }, + "SynonymSetService": { + "clients": { + "grpc": { + "libraryClient": "SynonymSetServiceClient", + "rpcs": { + "CreateSynonymSet": { + "methods": [ + "createSynonymSet" + ] + }, + "GetSynonymSet": { + "methods": [ + "getSynonymSet" + ] + }, + "UpdateSynonymSet": { + "methods": [ + "updateSynonymSet" + ] + }, + "DeleteSynonymSet": { + "methods": [ + "deleteSynonymSet" + ] + }, + "ListSynonymSets": { + "methods": [ + "listSynonymSets", + "listSynonymSetsStream", + "listSynonymSetsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "SynonymSetServiceClient", + "rpcs": { + "CreateSynonymSet": { + "methods": [ + "createSynonymSet" + ] + }, + "GetSynonymSet": { + "methods": [ + "getSynonymSet" + ] + }, + "UpdateSynonymSet": { + "methods": [ + "updateSynonymSet" + ] + }, + "DeleteSynonymSet": { + "methods": [ + "deleteSynonymSet" + ] + }, + "ListSynonymSets": { + "methods": [ + "listSynonymSets", + "listSynonymSetsStream", + "listSynonymSetsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/index.ts new file mode 100644 index 00000000000..de01f8e3028 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/index.ts @@ -0,0 +1,23 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {DocumentLinkServiceClient} from './document_link_service_client'; +export {DocumentSchemaServiceClient} from './document_schema_service_client'; +export {DocumentServiceClient} from './document_service_client'; +export {RuleSetServiceClient} from './rule_set_service_client'; +export {SynonymSetServiceClient} from './synonym_set_service_client'; diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client.ts new file mode 100644 index 00000000000..822720fb9dc --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client.ts @@ -0,0 +1,1144 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/rule_set_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './rule_set_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service to manage customer specific RuleSets. + * @class + * @memberof v1 + */ +export class RuleSetServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + ruleSetServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of RuleSetServiceClient. + * + * @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 RuleSetServiceClient({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 RuleSetServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + documentLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}' + ), + documentSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documentSchemas/{document_schema}' + ), + projectLocationDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/{document}' + ), + projectLocationDocumentsReferenceIdPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/referenceId/{reference_id}' + ), + ruleSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/ruleSets/{rule_set}' + ), + synonymSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/synonymSets/{context}' + ), + }; + + // 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 = { + listRuleSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'ruleSets') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.contentwarehouse.v1.RuleSetService', 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.ruleSetServiceStub) { + return this.ruleSetServiceStub; + } + + // Put together the "service stub" for + // google.cloud.contentwarehouse.v1.RuleSetService. + this.ruleSetServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.contentwarehouse.v1.RuleSetService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.contentwarehouse.v1.RuleSetService, + 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 ruleSetServiceStubMethods = + ['createRuleSet', 'getRuleSet', 'updateRuleSet', 'deleteRuleSet', 'listRuleSets']; + for (const methodName of ruleSetServiceStubMethods) { + const callPromise = this.ruleSetServiceStub.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.ruleSetServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'contentwarehouse.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 'contentwarehouse.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 ruleset. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent name. + * Format: projects/{project_number}/locations/{location}. + * @param {google.cloud.contentwarehouse.v1.RuleSet} request.ruleSet + * Required. The rule set to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/rule_set_service.create_rule_set.js + * region_tag:contentwarehouse_v1_generated_RuleSetService_CreateRuleSet_async + */ + createRuleSet( + request?: protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|undefined, {}|undefined + ]>; + createRuleSet( + request: protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|null|undefined, + {}|null|undefined>): void; + createRuleSet( + request: protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|null|undefined, + {}|null|undefined>): void; + createRuleSet( + request?: protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createRuleSet(request, options, callback); + } +/** + * Gets a ruleset. Returns NOT_FOUND if the ruleset does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the rule set to retrieve. + * Format: + * projects/{project_number}/locations/{location}/ruleSets/{rule_set_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 [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/rule_set_service.get_rule_set.js + * region_tag:contentwarehouse_v1_generated_RuleSetService_GetRuleSet_async + */ + getRuleSet( + request?: protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|undefined, {}|undefined + ]>; + getRuleSet( + request: protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|null|undefined, + {}|null|undefined>): void; + getRuleSet( + request: protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|null|undefined, + {}|null|undefined>): void; + getRuleSet( + request?: protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getRuleSet(request, options, callback); + } +/** + * Updates a ruleset. Returns INVALID_ARGUMENT if the name of the ruleset + * is non-empty and does not equal the existing name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the rule set to update. + * Format: + * projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. + * @param {google.cloud.contentwarehouse.v1.RuleSet} request.ruleSet + * Required. The rule set to update. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/rule_set_service.update_rule_set.js + * region_tag:contentwarehouse_v1_generated_RuleSetService_UpdateRuleSet_async + */ + updateRuleSet( + request?: protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|undefined, {}|undefined + ]>; + updateRuleSet( + request: protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|null|undefined, + {}|null|undefined>): void; + updateRuleSet( + request: protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|null|undefined, + {}|null|undefined>): void; + updateRuleSet( + request?: protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IRuleSet, + protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.updateRuleSet(request, options, callback); + } +/** + * Deletes a ruleset. Returns NOT_FOUND if the document does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the rule set to delete. + * Format: + * projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/rule_set_service.delete_rule_set.js + * region_tag:contentwarehouse_v1_generated_RuleSetService_DeleteRuleSet_async + */ + deleteRuleSet( + request?: protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|undefined, {}|undefined + ]>; + deleteRuleSet( + request: protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|null|undefined, + {}|null|undefined>): void; + deleteRuleSet( + request: protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|null|undefined, + {}|null|undefined>): void; + deleteRuleSet( + request?: protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteRuleSet(request, options, callback); + } + + /** + * Lists rulesets. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of document. + * Format: projects/{project_number}/locations/{location}. + * @param {number} request.pageSize + * The maximum number of rule sets to return. The service may return + * fewer than this value. + * If unspecified, at most 50 rule sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListRuleSets` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListRuleSets` + * must match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet}. + * 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 `listRuleSetsAsync()` + * 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. + */ + listRuleSets( + request?: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IRuleSet[], + protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest|null, + protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse + ]>; + listRuleSets( + request: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, + protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IRuleSet>): void; + listRuleSets( + request: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, + callback: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, + protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IRuleSet>): void; + listRuleSets( + request?: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, + protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IRuleSet>, + callback?: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, + protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.IRuleSet>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.IRuleSet[], + protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest|null, + protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listRuleSets(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, which owns this collection of document. + * Format: projects/{project_number}/locations/{location}. + * @param {number} request.pageSize + * The maximum number of rule sets to return. The service may return + * fewer than this value. + * If unspecified, at most 50 rule sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListRuleSets` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListRuleSets` + * must match the call that provided the page token. + * @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 [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet} 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 `listRuleSetsAsync()` + * 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. + */ + listRuleSetsStream( + request?: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, + 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['listRuleSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRuleSets.createStream( + this.innerApiCalls.listRuleSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listRuleSets`, 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, which owns this collection of document. + * Format: projects/{project_number}/locations/{location}. + * @param {number} request.pageSize + * The maximum number of rule sets to return. The service may return + * fewer than this value. + * If unspecified, at most 50 rule sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListRuleSets` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListRuleSets` + * must match the call that provided the 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 + * [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/rule_set_service.list_rule_sets.js + * region_tag:contentwarehouse_v1_generated_RuleSetService_ListRuleSets_async + */ + listRuleSetsAsync( + request?: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, + 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['listRuleSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listRuleSets.asyncIterate( + this.innerApiCalls['listRuleSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified documentLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document + * @param {string} document_link + * @returns {string} Resource name string. + */ + documentLinkPath(project:string,location:string,document:string,documentLink:string) { + return this.pathTemplates.documentLinkPathTemplate.render({ + project: project, + location: location, + document: document, + document_link: documentLink, + }); + } + + /** + * Parse the project from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).project; + } + + /** + * Parse the location from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).location; + } + + /** + * Parse the document from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document; + } + + /** + * Parse the document_link from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the document_link. + */ + matchDocumentLinkFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document_link; + } + + /** + * Return a fully-qualified documentSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document_schema + * @returns {string} Resource name string. + */ + documentSchemaPath(project:string,location:string,documentSchema:string) { + return this.pathTemplates.documentSchemaPathTemplate.render({ + project: project, + location: location, + document_schema: documentSchema, + }); + } + + /** + * Parse the project from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).project; + } + + /** + * Parse the location from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).location; + } + + /** + * Parse the document_schema from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the document_schema. + */ + matchDocumentSchemaFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).document_schema; + } + + /** + * Return a fully-qualified projectLocationDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDocumentPath(project:string,location:string,document:string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.render({ + project: project, + location: location, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).location; + } + + /** + * Parse the document from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDocumentsReferenceId resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} reference_id + * @returns {string} Resource name string. + */ + projectLocationDocumentsReferenceIdPath(project:string,location:string,referenceId:string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render({ + project: project, + location: location, + reference_id: referenceId, + }); + } + + /** + * Parse the project from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).project; + } + + /** + * Parse the location from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).location; + } + + /** + * Parse the reference_id from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the reference_id. + */ + matchReferenceIdFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).reference_id; + } + + /** + * Return a fully-qualified ruleSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} rule_set + * @returns {string} Resource name string. + */ + ruleSetPath(project:string,location:string,ruleSet:string) { + return this.pathTemplates.ruleSetPathTemplate.render({ + project: project, + location: location, + rule_set: ruleSet, + }); + } + + /** + * Parse the project from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).project; + } + + /** + * Parse the location from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).location; + } + + /** + * Parse the rule_set from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the rule_set. + */ + matchRuleSetFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).rule_set; + } + + /** + * Return a fully-qualified synonymSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} context + * @returns {string} Resource name string. + */ + synonymSetPath(project:string,location:string,context:string) { + return this.pathTemplates.synonymSetPathTemplate.render({ + project: project, + location: location, + context: context, + }); + } + + /** + * Parse the project from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).project; + } + + /** + * Parse the location from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).location; + } + + /** + * Parse the context from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the context. + */ + matchContextFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).context; + } + + /** + * 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.ruleSetServiceStub && !this._terminated) { + return this.ruleSetServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client_config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client_config.json new file mode 100644 index 00000000000..e5e5bf93f5d --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client_config.json @@ -0,0 +1,63 @@ +{ + "interfaces": { + "google.cloud.contentwarehouse.v1.RuleSetService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateRuleSet": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetRuleSet": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateRuleSet": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteRuleSet": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListRuleSets": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_proto_list.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_proto_list.json new file mode 100644 index 00000000000..e85ca71c0c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/common.proto", + "../../protos/google/cloud/contentwarehouse/v1/document.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_link_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_schema.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_schema_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/filters.proto", + "../../protos/google/cloud/contentwarehouse/v1/histogram.proto", + "../../protos/google/cloud/contentwarehouse/v1/rule_engine.proto", + "../../protos/google/cloud/contentwarehouse/v1/ruleset_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto", + "../../protos/google/cloud/documentai/v1/barcode.proto", + "../../protos/google/cloud/documentai/v1/document.proto", + "../../protos/google/cloud/documentai/v1/geometry.proto" +] diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client.ts new file mode 100644 index 00000000000..2c6233fa404 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client.ts @@ -0,0 +1,1150 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/synonym_set_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './synonym_set_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * A Service that manage/custom customer specified SynonymSets. + * @class + * @memberof v1 + */ +export class SynonymSetServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + synonymSetServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of SynonymSetServiceClient. + * + * @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 SynonymSetServiceClient({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 SynonymSetServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + documentLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}' + ), + documentSchemaPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documentSchemas/{document_schema}' + ), + projectLocationDocumentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/{document}' + ), + projectLocationDocumentsReferenceIdPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/documents/referenceId/{reference_id}' + ), + ruleSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/ruleSets/{rule_set}' + ), + synonymSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/synonymSets/{context}' + ), + }; + + // 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 = { + listSynonymSets: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'synonymSets') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.contentwarehouse.v1.SynonymSetService', 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.synonymSetServiceStub) { + return this.synonymSetServiceStub; + } + + // Put together the "service stub" for + // google.cloud.contentwarehouse.v1.SynonymSetService. + this.synonymSetServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.contentwarehouse.v1.SynonymSetService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.contentwarehouse.v1.SynonymSetService, + 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 synonymSetServiceStubMethods = + ['createSynonymSet', 'getSynonymSet', 'updateSynonymSet', 'deleteSynonymSet', 'listSynonymSets']; + for (const methodName of synonymSetServiceStubMethods) { + const callPromise = this.synonymSetServiceStub.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.synonymSetServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'contentwarehouse.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 'contentwarehouse.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 SynonymSet for a single context. + * Throws an ALREADY_EXISTS exception if a synonymset already exists + * for the context. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent name. + * Format: projects/{project_number}/locations/{location}. + * @param {google.cloud.contentwarehouse.v1.SynonymSet} request.synonymSet + * Required. The synonymSet to be created for a context + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/synonym_set_service.create_synonym_set.js + * region_tag:contentwarehouse_v1_generated_SynonymSetService_CreateSynonymSet_async + */ + createSynonymSet( + request?: protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|undefined, {}|undefined + ]>; + createSynonymSet( + request: protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|null|undefined, + {}|null|undefined>): void; + createSynonymSet( + request: protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|null|undefined, + {}|null|undefined>): void; + createSynonymSet( + request?: protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.createSynonymSet(request, options, callback); + } +/** + * Gets a SynonymSet for a particular context. + * Throws a NOT_FOUND exception if the Synonymset + * does not exist + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the synonymSet to retrieve + * Format: + * projects/{project_number}/locations/{location}/synonymSets/{context}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/synonym_set_service.get_synonym_set.js + * region_tag:contentwarehouse_v1_generated_SynonymSetService_GetSynonymSet_async + */ + getSynonymSet( + request?: protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|undefined, {}|undefined + ]>; + getSynonymSet( + request: protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|null|undefined, + {}|null|undefined>): void; + getSynonymSet( + request: protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|null|undefined, + {}|null|undefined>): void; + getSynonymSet( + request?: protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.getSynonymSet(request, options, callback); + } +/** + * Remove the existing SynonymSet for the context and replaces it + * with a new one. + * Throws a NOT_FOUND exception if the SynonymSet is not found. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the synonymSet to update + * Format: + * projects/{project_number}/locations/{location}/synonymSets/{context}. + * @param {google.cloud.contentwarehouse.v1.SynonymSet} request.synonymSet + * Required. The synonymSet to be updated for the customer + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/synonym_set_service.update_synonym_set.js + * region_tag:contentwarehouse_v1_generated_SynonymSetService_UpdateSynonymSet_async + */ + updateSynonymSet( + request?: protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|undefined, {}|undefined + ]>; + updateSynonymSet( + request: protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|null|undefined, + {}|null|undefined>): void; + updateSynonymSet( + request: protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest, + callback: Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|null|undefined, + {}|null|undefined>): void; + updateSynonymSet( + request?: protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ISynonymSet, + protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.updateSynonymSet(request, options, callback); + } +/** + * Deletes a SynonymSet for a given context. + * Throws a NOT_FOUND exception if the SynonymSet is not found. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the synonymSet to delete + * Format: + * projects/{project_number}/locations/{location}/synonymSets/{context}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/synonym_set_service.delete_synonym_set.js + * region_tag:contentwarehouse_v1_generated_SynonymSetService_DeleteSynonymSet_async + */ + deleteSynonymSet( + request?: protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|undefined, {}|undefined + ]>; + deleteSynonymSet( + request: protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|null|undefined, + {}|null|undefined>): void; + deleteSynonymSet( + request: protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|null|undefined, + {}|null|undefined>): void; + deleteSynonymSet( + request?: protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.deleteSynonymSet(request, options, callback); + } + + /** + * Returns all SynonymSets (for all contexts) for the specified location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent name. + * Format: projects/{project_number}/locations/{location}. + * @param {number} request.pageSize + * The maximum number of synonymSets to return. The service may return + * fewer than this value. + * If unspecified, at most 50 rule sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListSynonymSets` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListSynonymSets` + * must match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet}. + * 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 `listSynonymSetsAsync()` + * 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. + */ + listSynonymSets( + request?: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ISynonymSet[], + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest|null, + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse + ]>; + listSynonymSets( + request: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.ISynonymSet>): void; + listSynonymSets( + request: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, + callback: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.ISynonymSet>): void; + listSynonymSets( + request?: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.ISynonymSet>, + callback?: PaginationCallback< + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse|null|undefined, + protos.google.cloud.contentwarehouse.v1.ISynonymSet>): + Promise<[ + protos.google.cloud.contentwarehouse.v1.ISynonymSet[], + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest|null, + protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as 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.listSynonymSets(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 name. + * Format: projects/{project_number}/locations/{location}. + * @param {number} request.pageSize + * The maximum number of synonymSets to return. The service may return + * fewer than this value. + * If unspecified, at most 50 rule sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListSynonymSets` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListSynonymSets` + * must match the call that provided the page token. + * @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 [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet} 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 `listSynonymSetsAsync()` + * 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. + */ + listSynonymSetsStream( + request?: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, + 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['listSynonymSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSynonymSets.createStream( + this.innerApiCalls.listSynonymSets as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listSynonymSets`, 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 name. + * Format: projects/{project_number}/locations/{location}. + * @param {number} request.pageSize + * The maximum number of synonymSets to return. The service may return + * fewer than this value. + * If unspecified, at most 50 rule sets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListSynonymSets` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListSynonymSets` + * must match the call that provided the 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 + * [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/synonym_set_service.list_synonym_sets.js + * region_tag:contentwarehouse_v1_generated_SynonymSetService_ListSynonymSets_async + */ + listSynonymSetsAsync( + request?: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, + 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['listSynonymSets']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listSynonymSets.asyncIterate( + this.innerApiCalls['listSynonymSets'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified documentLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document + * @param {string} document_link + * @returns {string} Resource name string. + */ + documentLinkPath(project:string,location:string,document:string,documentLink:string) { + return this.pathTemplates.documentLinkPathTemplate.render({ + project: project, + location: location, + document: document, + document_link: documentLink, + }); + } + + /** + * Parse the project from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).project; + } + + /** + * Parse the location from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).location; + } + + /** + * Parse the document from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document; + } + + /** + * Parse the document_link from DocumentLink resource. + * + * @param {string} documentLinkName + * A fully-qualified path representing DocumentLink resource. + * @returns {string} A string representing the document_link. + */ + matchDocumentLinkFromDocumentLinkName(documentLinkName: string) { + return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document_link; + } + + /** + * Return a fully-qualified documentSchema resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document_schema + * @returns {string} Resource name string. + */ + documentSchemaPath(project:string,location:string,documentSchema:string) { + return this.pathTemplates.documentSchemaPathTemplate.render({ + project: project, + location: location, + document_schema: documentSchema, + }); + } + + /** + * Parse the project from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).project; + } + + /** + * Parse the location from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).location; + } + + /** + * Parse the document_schema from DocumentSchema resource. + * + * @param {string} documentSchemaName + * A fully-qualified path representing DocumentSchema resource. + * @returns {string} A string representing the document_schema. + */ + matchDocumentSchemaFromDocumentSchemaName(documentSchemaName: string) { + return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).document_schema; + } + + /** + * Return a fully-qualified projectLocationDocument resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} document + * @returns {string} Resource name string. + */ + projectLocationDocumentPath(project:string,location:string,document:string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.render({ + project: project, + location: location, + document: document, + }); + } + + /** + * Parse the project from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).project; + } + + /** + * Parse the location from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).location; + } + + /** + * Parse the document from ProjectLocationDocument resource. + * + * @param {string} projectLocationDocumentName + * A fully-qualified path representing project_location_document resource. + * @returns {string} A string representing the document. + */ + matchDocumentFromProjectLocationDocumentName(projectLocationDocumentName: string) { + return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).document; + } + + /** + * Return a fully-qualified projectLocationDocumentsReferenceId resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} reference_id + * @returns {string} Resource name string. + */ + projectLocationDocumentsReferenceIdPath(project:string,location:string,referenceId:string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render({ + project: project, + location: location, + reference_id: referenceId, + }); + } + + /** + * Parse the project from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).project; + } + + /** + * Parse the location from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).location; + } + + /** + * Parse the reference_id from ProjectLocationDocumentsReferenceId resource. + * + * @param {string} projectLocationDocumentsReferenceIdName + * A fully-qualified path representing project_location_documents_reference_id resource. + * @returns {string} A string representing the reference_id. + */ + matchReferenceIdFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { + return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).reference_id; + } + + /** + * Return a fully-qualified ruleSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} rule_set + * @returns {string} Resource name string. + */ + ruleSetPath(project:string,location:string,ruleSet:string) { + return this.pathTemplates.ruleSetPathTemplate.render({ + project: project, + location: location, + rule_set: ruleSet, + }); + } + + /** + * Parse the project from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).project; + } + + /** + * Parse the location from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).location; + } + + /** + * Parse the rule_set from RuleSet resource. + * + * @param {string} ruleSetName + * A fully-qualified path representing RuleSet resource. + * @returns {string} A string representing the rule_set. + */ + matchRuleSetFromRuleSetName(ruleSetName: string) { + return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).rule_set; + } + + /** + * Return a fully-qualified synonymSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} context + * @returns {string} Resource name string. + */ + synonymSetPath(project:string,location:string,context:string) { + return this.pathTemplates.synonymSetPathTemplate.render({ + project: project, + location: location, + context: context, + }); + } + + /** + * Parse the project from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).project; + } + + /** + * Parse the location from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).location; + } + + /** + * Parse the context from SynonymSet resource. + * + * @param {string} synonymSetName + * A fully-qualified path representing SynonymSet resource. + * @returns {string} A string representing the context. + */ + matchContextFromSynonymSetName(synonymSetName: string) { + return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).context; + } + + /** + * 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.synonymSetServiceStub && !this._terminated) { + return this.synonymSetServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client_config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client_config.json new file mode 100644 index 00000000000..3c3408c02f7 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client_config.json @@ -0,0 +1,63 @@ +{ + "interfaces": { + "google.cloud.contentwarehouse.v1.SynonymSetService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateSynonymSet": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetSynonymSet": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateSynonymSet": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteSynonymSet": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListSynonymSets": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_proto_list.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_proto_list.json new file mode 100644 index 00000000000..e85ca71c0c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/common.proto", + "../../protos/google/cloud/contentwarehouse/v1/document.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_link_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_schema.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_schema_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/document_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/filters.proto", + "../../protos/google/cloud/contentwarehouse/v1/histogram.proto", + "../../protos/google/cloud/contentwarehouse/v1/rule_engine.proto", + "../../protos/google/cloud/contentwarehouse/v1/ruleset_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset_service.proto", + "../../protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto", + "../../protos/google/cloud/documentai/v1/barcode.proto", + "../../protos/google/cloud/documentai/v1/document.proto", + "../../protos/google/cloud/documentai/v1/geometry.proto" +] diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..e090049671f --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,31 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 contentwarehouse = require('@google-cloud/contentwarehouse'); + +function main() { + const documentLinkServiceClient = new contentwarehouse.DocumentLinkServiceClient(); + const documentSchemaServiceClient = new contentwarehouse.DocumentSchemaServiceClient(); + const documentServiceClient = new contentwarehouse.DocumentServiceClient(); + const ruleSetServiceClient = new contentwarehouse.RuleSetServiceClient(); + const synonymSetServiceClient = new contentwarehouse.SynonymSetServiceClient(); +} + +main(); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..19092f5daa3 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,56 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {DocumentLinkServiceClient, DocumentSchemaServiceClient, DocumentServiceClient, RuleSetServiceClient, SynonymSetServiceClient} from '@google-cloud/contentwarehouse'; + +// check that the client class type name can be used +function doStuffWithDocumentLinkServiceClient(client: DocumentLinkServiceClient) { + client.close(); +} +function doStuffWithDocumentSchemaServiceClient(client: DocumentSchemaServiceClient) { + client.close(); +} +function doStuffWithDocumentServiceClient(client: DocumentServiceClient) { + client.close(); +} +function doStuffWithRuleSetServiceClient(client: RuleSetServiceClient) { + client.close(); +} +function doStuffWithSynonymSetServiceClient(client: SynonymSetServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const documentLinkServiceClient = new DocumentLinkServiceClient(); + doStuffWithDocumentLinkServiceClient(documentLinkServiceClient); + // check that the client instance can be created + const documentSchemaServiceClient = new DocumentSchemaServiceClient(); + doStuffWithDocumentSchemaServiceClient(documentSchemaServiceClient); + // check that the client instance can be created + const documentServiceClient = new DocumentServiceClient(); + doStuffWithDocumentServiceClient(documentServiceClient); + // check that the client instance can be created + const ruleSetServiceClient = new RuleSetServiceClient(); + doStuffWithRuleSetServiceClient(ruleSetServiceClient); + // check that the client instance can be created + const synonymSetServiceClient = new SynonymSetServiceClient(); + doStuffWithSynonymSetServiceClient(synonymSetServiceClient); +} + +main(); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/install.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_link_service_v1.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_link_service_v1.ts new file mode 100644 index 00000000000..18ef476e34b --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_link_service_v1.ts @@ -0,0 +1,1053 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 documentlinkserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DocumentLinkServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = documentlinkserviceModule.v1.DocumentLinkServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = documentlinkserviceModule.v1.DocumentLinkServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = documentlinkserviceModule.v1.DocumentLinkServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentLinkServiceStub, undefined); + await client.initialize(); + assert(client.documentLinkServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.documentLinkServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentLinkServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + 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 documentlinkserviceModule.v1.DocumentLinkServiceClient({ + 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('listLinkedTargets', () => { + it('invokes listLinkedTargets without error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsResponse() + ); + client.innerApiCalls.listLinkedTargets = stubSimpleCall(expectedResponse); + const [response] = await client.listLinkedTargets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listLinkedTargets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLinkedTargets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLinkedTargets without error using callback', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsResponse() + ); + client.innerApiCalls.listLinkedTargets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listLinkedTargets( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listLinkedTargets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLinkedTargets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLinkedTargets with error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listLinkedTargets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listLinkedTargets(request), expectedError); + const actualRequest = (client.innerApiCalls.listLinkedTargets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLinkedTargets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLinkedTargets with closed client', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listLinkedTargets(request), expectedError); + }); + }); + + describe('createDocumentLink', () => { + it('invokes createDocumentLink without error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DocumentLink() + ); + client.innerApiCalls.createDocumentLink = stubSimpleCall(expectedResponse); + const [response] = await client.createDocumentLink(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocumentLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocumentLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocumentLink without error using callback', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DocumentLink() + ); + client.innerApiCalls.createDocumentLink = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDocumentLink( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentLink|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocumentLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocumentLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocumentLink with error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocumentLink = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocumentLink(request), expectedError); + const actualRequest = (client.innerApiCalls.createDocumentLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocumentLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocumentLink with closed client', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDocumentLink(request), expectedError); + }); + }); + + describe('deleteDocumentLink', () => { + it('invokes deleteDocumentLink without error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocumentLink = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocumentLink(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocumentLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocumentLink without error using callback', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocumentLink = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDocumentLink( + 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.deleteDocumentLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocumentLink with error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocumentLink = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocumentLink(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteDocumentLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocumentLink with closed client', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDocumentLink(request), expectedError); + }); + }); + + describe('listLinkedSources', () => { + it('invokes listLinkedSources without error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + ]; + client.innerApiCalls.listLinkedSources = stubSimpleCall(expectedResponse); + const [response] = await client.listLinkedSources(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listLinkedSources as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLinkedSources as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLinkedSources without error using callback', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + ]; + client.innerApiCalls.listLinkedSources = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listLinkedSources( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentLink[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listLinkedSources as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLinkedSources as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLinkedSources with error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listLinkedSources = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listLinkedSources(request), expectedError); + const actualRequest = (client.innerApiCalls.listLinkedSources as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listLinkedSources as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listLinkedSourcesStream without error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + ]; + client.descriptors.page.listLinkedSources.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listLinkedSourcesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.contentwarehouse.v1.DocumentLink[] = []; + stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.DocumentLink) => { + 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.listLinkedSources.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listLinkedSources, request)); + assert( + (client.descriptors.page.listLinkedSources.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listLinkedSourcesStream with error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLinkedSources.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listLinkedSourcesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.contentwarehouse.v1.DocumentLink[] = []; + stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.DocumentLink) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listLinkedSources.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listLinkedSources, request)); + assert( + (client.descriptors.page.listLinkedSources.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listLinkedSources without error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), + ]; + client.descriptors.page.listLinkedSources.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.contentwarehouse.v1.IDocumentLink[] = []; + const iterable = client.listLinkedSourcesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listLinkedSources.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listLinkedSources.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listLinkedSources with error', async () => { + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listLinkedSources.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLinkedSourcesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.contentwarehouse.v1.IDocumentLink[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listLinkedSources.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listLinkedSources.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('documentLink', () => { + const fakePath = "/rendered/path/documentLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document: "documentValue", + document_link: "documentLinkValue", + }; + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.documentLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('documentLinkPath', () => { + const result = client.documentLinkPath("projectValue", "locationValue", "documentValue", "documentLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.documentLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDocumentLinkName', () => { + const result = client.matchProjectFromDocumentLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDocumentLinkName', () => { + const result = client.matchLocationFromDocumentLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromDocumentLinkName', () => { + const result = client.matchDocumentFromDocumentLinkName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentLinkFromDocumentLinkName', () => { + const result = client.matchDocumentLinkFromDocumentLinkName(fakePath); + assert.strictEqual(result, "documentLinkValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('documentSchema', () => { + const fakePath = "/rendered/path/documentSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document_schema: "documentSchemaValue", + }; + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.documentSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('documentSchemaPath', () => { + const result = client.documentSchemaPath("projectValue", "locationValue", "documentSchemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.documentSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDocumentSchemaName', () => { + const result = client.matchProjectFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDocumentSchemaName', () => { + const result = client.matchLocationFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentSchemaFromDocumentSchemaName', () => { + const result = client.matchDocumentSchemaFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "documentSchemaValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDocument', () => { + const fakePath = "/rendered/path/projectLocationDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document: "documentValue", + }; + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDocumentPath', () => { + const result = client.projectLocationDocumentPath("projectValue", "locationValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDocumentName', () => { + const result = client.matchProjectFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDocumentName', () => { + const result = client.matchLocationFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDocumentsReferenceId', () => { + const fakePath = "/rendered/path/projectLocationDocumentsReferenceId"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + reference_id: "referenceIdValue", + }; + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDocumentsReferenceIdPath', () => { + const result = client.projectLocationDocumentsReferenceIdPath("projectValue", "locationValue", "referenceIdValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchProjectFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchLocationFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceIdFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchReferenceIdFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "referenceIdValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('ruleSet', () => { + const fakePath = "/rendered/path/ruleSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + rule_set: "ruleSetValue", + }; + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.ruleSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.ruleSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('ruleSetPath', () => { + const result = client.ruleSetPath("projectValue", "locationValue", "ruleSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.ruleSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRuleSetName', () => { + const result = client.matchProjectFromRuleSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRuleSetName', () => { + const result = client.matchLocationFromRuleSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRuleSetFromRuleSetName', () => { + const result = client.matchRuleSetFromRuleSetName(fakePath); + assert.strictEqual(result, "ruleSetValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('synonymSet', () => { + const fakePath = "/rendered/path/synonymSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + context: "contextValue", + }; + const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.synonymSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.synonymSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('synonymSetPath', () => { + const result = client.synonymSetPath("projectValue", "locationValue", "contextValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.synonymSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromSynonymSetName', () => { + const result = client.matchProjectFromSynonymSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromSynonymSetName', () => { + const result = client.matchLocationFromSynonymSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchContextFromSynonymSetName', () => { + const result = client.matchContextFromSynonymSetName(fakePath); + assert.strictEqual(result, "contextValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_schema_service_v1.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_schema_service_v1.ts new file mode 100644 index 00000000000..8a8effa2119 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_schema_service_v1.ts @@ -0,0 +1,1199 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 documentschemaserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DocumentSchemaServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = documentschemaserviceModule.v1.DocumentSchemaServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = documentschemaserviceModule.v1.DocumentSchemaServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = documentschemaserviceModule.v1.DocumentSchemaServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentSchemaServiceStub, undefined); + await client.initialize(); + assert(client.documentSchemaServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.documentSchemaServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentSchemaServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + 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 documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + 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('createDocumentSchema', () => { + it('invokes createDocumentSchema without error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DocumentSchema() + ); + client.innerApiCalls.createDocumentSchema = stubSimpleCall(expectedResponse); + const [response] = await client.createDocumentSchema(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocumentSchema without error using callback', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DocumentSchema() + ); + client.innerApiCalls.createDocumentSchema = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDocumentSchema( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentSchema|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocumentSchema with error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocumentSchema = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocumentSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.createDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocumentSchema with closed client', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDocumentSchema(request), expectedError); + }); + }); + + describe('updateDocumentSchema', () => { + it('invokes updateDocumentSchema without error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DocumentSchema() + ); + client.innerApiCalls.updateDocumentSchema = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocumentSchema(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocumentSchema without error using callback', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DocumentSchema() + ); + client.innerApiCalls.updateDocumentSchema = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDocumentSchema( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentSchema|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocumentSchema with error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocumentSchema = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDocumentSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocumentSchema with closed client', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDocumentSchema(request), expectedError); + }); + }); + + describe('getDocumentSchema', () => { + it('invokes getDocumentSchema without error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DocumentSchema() + ); + client.innerApiCalls.getDocumentSchema = stubSimpleCall(expectedResponse); + const [response] = await client.getDocumentSchema(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocumentSchema without error using callback', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DocumentSchema() + ); + client.innerApiCalls.getDocumentSchema = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDocumentSchema( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentSchema|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocumentSchema with error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocumentSchema = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDocumentSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.getDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocumentSchema with closed client', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDocumentSchema(request), expectedError); + }); + }); + + describe('deleteDocumentSchema', () => { + it('invokes deleteDocumentSchema without error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocumentSchema = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocumentSchema(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocumentSchema without error using callback', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocumentSchema = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDocumentSchema( + 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.deleteDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocumentSchema with error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocumentSchema = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocumentSchema(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteDocumentSchema as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentSchema as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocumentSchema with closed client', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDocumentSchema(request), expectedError); + }); + }); + + describe('listDocumentSchemas', () => { + it('invokes listDocumentSchemas without error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + ]; + client.innerApiCalls.listDocumentSchemas = stubSimpleCall(expectedResponse); + const [response] = await client.listDocumentSchemas(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDocumentSchemas as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocumentSchemas as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDocumentSchemas without error using callback', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + ]; + client.innerApiCalls.listDocumentSchemas = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDocumentSchemas( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentSchema[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listDocumentSchemas as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocumentSchemas as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDocumentSchemas with error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDocumentSchemas = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDocumentSchemas(request), expectedError); + const actualRequest = (client.innerApiCalls.listDocumentSchemas as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listDocumentSchemas as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDocumentSchemasStream without error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + ]; + client.descriptors.page.listDocumentSchemas.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listDocumentSchemasStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.contentwarehouse.v1.DocumentSchema[] = []; + stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.DocumentSchema) => { + 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.listDocumentSchemas.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDocumentSchemas, request)); + assert( + (client.descriptors.page.listDocumentSchemas.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listDocumentSchemasStream with error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDocumentSchemas.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listDocumentSchemasStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.contentwarehouse.v1.DocumentSchema[] = []; + stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.DocumentSchema) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listDocumentSchemas.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDocumentSchemas, request)); + assert( + (client.descriptors.page.listDocumentSchemas.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDocumentSchemas without error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), + ]; + client.descriptors.page.listDocumentSchemas.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.contentwarehouse.v1.IDocumentSchema[] = []; + const iterable = client.listDocumentSchemasAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDocumentSchemas.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDocumentSchemas.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDocumentSchemas with error', async () => { + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDocumentSchemas.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDocumentSchemasAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.contentwarehouse.v1.IDocumentSchema[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDocumentSchemas.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listDocumentSchemas.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('documentLink', () => { + const fakePath = "/rendered/path/documentLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document: "documentValue", + document_link: "documentLinkValue", + }; + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.documentLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('documentLinkPath', () => { + const result = client.documentLinkPath("projectValue", "locationValue", "documentValue", "documentLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.documentLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDocumentLinkName', () => { + const result = client.matchProjectFromDocumentLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDocumentLinkName', () => { + const result = client.matchLocationFromDocumentLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromDocumentLinkName', () => { + const result = client.matchDocumentFromDocumentLinkName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentLinkFromDocumentLinkName', () => { + const result = client.matchDocumentLinkFromDocumentLinkName(fakePath); + assert.strictEqual(result, "documentLinkValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('documentSchema', () => { + const fakePath = "/rendered/path/documentSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document_schema: "documentSchemaValue", + }; + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.documentSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('documentSchemaPath', () => { + const result = client.documentSchemaPath("projectValue", "locationValue", "documentSchemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.documentSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDocumentSchemaName', () => { + const result = client.matchProjectFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDocumentSchemaName', () => { + const result = client.matchLocationFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentSchemaFromDocumentSchemaName', () => { + const result = client.matchDocumentSchemaFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "documentSchemaValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + 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('projectLocationDocument', () => { + const fakePath = "/rendered/path/projectLocationDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document: "documentValue", + }; + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDocumentPath', () => { + const result = client.projectLocationDocumentPath("projectValue", "locationValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDocumentName', () => { + const result = client.matchProjectFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDocumentName', () => { + const result = client.matchLocationFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDocumentsReferenceId', () => { + const fakePath = "/rendered/path/projectLocationDocumentsReferenceId"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + reference_id: "referenceIdValue", + }; + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDocumentsReferenceIdPath', () => { + const result = client.projectLocationDocumentsReferenceIdPath("projectValue", "locationValue", "referenceIdValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchProjectFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchLocationFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceIdFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchReferenceIdFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "referenceIdValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('ruleSet', () => { + const fakePath = "/rendered/path/ruleSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + rule_set: "ruleSetValue", + }; + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.ruleSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.ruleSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('ruleSetPath', () => { + const result = client.ruleSetPath("projectValue", "locationValue", "ruleSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.ruleSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRuleSetName', () => { + const result = client.matchProjectFromRuleSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRuleSetName', () => { + const result = client.matchLocationFromRuleSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRuleSetFromRuleSetName', () => { + const result = client.matchRuleSetFromRuleSetName(fakePath); + assert.strictEqual(result, "ruleSetValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('synonymSet', () => { + const fakePath = "/rendered/path/synonymSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + context: "contextValue", + }; + const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.synonymSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.synonymSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('synonymSetPath', () => { + const result = client.synonymSetPath("projectValue", "locationValue", "contextValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.synonymSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromSynonymSetName', () => { + const result = client.matchProjectFromSynonymSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromSynonymSetName', () => { + const result = client.matchLocationFromSynonymSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchContextFromSynonymSetName', () => { + const result = client.matchContextFromSynonymSetName(fakePath); + assert.strictEqual(result, "contextValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_service_v1.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_service_v1.ts new file mode 100644 index 00000000000..fb6f457b40f --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_service_v1.ts @@ -0,0 +1,1377 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 documentserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DocumentServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = documentserviceModule.v1.DocumentServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = documentserviceModule.v1.DocumentServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = documentserviceModule.v1.DocumentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new documentserviceModule.v1.DocumentServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentServiceStub, undefined); + await client.initialize(); + assert(client.documentServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.documentServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentserviceModule.v1.DocumentServiceClient({ + 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 documentserviceModule.v1.DocumentServiceClient({ + 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('createDocument', () => { + it('invokes createDocument without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentResponse() + ); + client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); + const [response] = await client.createDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocument without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentResponse() + ); + client.innerApiCalls.createDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDocument( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocument with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDocument with closed client', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDocument(request), expectedError); + }); + }); + + describe('getDocument', () => { + it('invokes getDocument without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); + const [response] = await client.getDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocument without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.Document() + ); + client.innerApiCalls.getDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDocument( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocument with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDocument with closed client', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDocument(request), expectedError); + }); + }); + + describe('updateDocument', () => { + it('invokes updateDocument without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateDocumentResponse() + ); + client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); + const [response] = await client.updateDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocument without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateDocumentResponse() + ); + client.innerApiCalls.updateDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDocument( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocument with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDocument with closed client', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDocument(request), expectedError); + }); + }); + + describe('deleteDocument', () => { + it('invokes deleteDocument without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDocument(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocument without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDocument( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocument with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDocument with closed client', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteDocumentRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDocument(request), expectedError); + }); + }); + + describe('fetchAcl', () => { + it('invokes fetchAcl without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.FetchAclRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.FetchAclRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.FetchAclResponse() + ); + client.innerApiCalls.fetchAcl = stubSimpleCall(expectedResponse); + const [response] = await client.fetchAcl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.fetchAcl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchAcl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchAcl without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.FetchAclRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.FetchAclRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.FetchAclResponse() + ); + client.innerApiCalls.fetchAcl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.fetchAcl( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IFetchAclResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.fetchAcl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchAcl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchAcl with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.FetchAclRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.FetchAclRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.fetchAcl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.fetchAcl(request), expectedError); + const actualRequest = (client.innerApiCalls.fetchAcl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchAcl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchAcl with closed client', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.FetchAclRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.FetchAclRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.fetchAcl(request), expectedError); + }); + }); + + describe('setAcl', () => { + it('invokes setAcl without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SetAclRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SetAclRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SetAclResponse() + ); + client.innerApiCalls.setAcl = stubSimpleCall(expectedResponse); + const [response] = await client.setAcl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setAcl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setAcl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setAcl without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SetAclRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SetAclRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SetAclResponse() + ); + client.innerApiCalls.setAcl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setAcl( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ISetAclResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setAcl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setAcl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setAcl with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SetAclRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SetAclRequest', ['resource']); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setAcl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setAcl(request), expectedError); + const actualRequest = (client.innerApiCalls.setAcl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setAcl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setAcl with closed client', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SetAclRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SetAclRequest', ['resource']); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setAcl(request), expectedError); + }); + }); + + describe('searchDocuments', () => { + it('invokes searchDocuments without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + ]; + client.innerApiCalls.searchDocuments = stubSimpleCall(expectedResponse); + const [response] = await client.searchDocuments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.searchDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchDocuments without error using callback', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + ]; + client.innerApiCalls.searchDocuments = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchDocuments( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.searchDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchDocuments with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchDocuments = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.searchDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.searchDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchDocumentsStream without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + ]; + client.descriptors.page.searchDocuments.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument[] = []; + stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument) => { + 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.searchDocuments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchDocuments, request)); + assert( + (client.descriptors.page.searchDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes searchDocumentsStream with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchDocuments.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchDocumentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument[] = []; + stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.searchDocuments.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchDocuments, request)); + assert( + (client.descriptors.page.searchDocuments.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with searchDocuments without error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), + ]; + client.descriptors.page.searchDocuments.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument[] = []; + const iterable = client.searchDocumentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchDocuments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.searchDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with searchDocuments with error', async () => { + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchDocuments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchDocumentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchDocuments.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.searchDocuments.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('documentLink', () => { + const fakePath = "/rendered/path/documentLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document: "documentValue", + document_link: "documentLinkValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.documentLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('documentLinkPath', () => { + const result = client.documentLinkPath("projectValue", "locationValue", "documentValue", "documentLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.documentLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDocumentLinkName', () => { + const result = client.matchProjectFromDocumentLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDocumentLinkName', () => { + const result = client.matchLocationFromDocumentLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromDocumentLinkName', () => { + const result = client.matchDocumentFromDocumentLinkName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentLinkFromDocumentLinkName', () => { + const result = client.matchDocumentLinkFromDocumentLinkName(fakePath); + assert.strictEqual(result, "documentLinkValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('documentSchema', () => { + const fakePath = "/rendered/path/documentSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document_schema: "documentSchemaValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.documentSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('documentSchemaPath', () => { + const result = client.documentSchemaPath("projectValue", "locationValue", "documentSchemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.documentSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDocumentSchemaName', () => { + const result = client.matchProjectFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDocumentSchemaName', () => { + const result = client.matchLocationFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentSchemaFromDocumentSchemaName', () => { + const result = client.matchDocumentSchemaFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "documentSchemaValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDocument', () => { + const fakePath = "/rendered/path/projectLocationDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document: "documentValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDocumentPath', () => { + const result = client.projectLocationDocumentPath("projectValue", "locationValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDocumentName', () => { + const result = client.matchProjectFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDocumentName', () => { + const result = client.matchLocationFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDocumentsReferenceId', () => { + const fakePath = "/rendered/path/projectLocationDocumentsReferenceId"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + reference_id: "referenceIdValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDocumentsReferenceIdPath', () => { + const result = client.projectLocationDocumentsReferenceIdPath("projectValue", "locationValue", "referenceIdValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchProjectFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchLocationFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceIdFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchReferenceIdFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "referenceIdValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('ruleSet', () => { + const fakePath = "/rendered/path/ruleSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + rule_set: "ruleSetValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.ruleSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.ruleSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('ruleSetPath', () => { + const result = client.ruleSetPath("projectValue", "locationValue", "ruleSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.ruleSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRuleSetName', () => { + const result = client.matchProjectFromRuleSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRuleSetName', () => { + const result = client.matchLocationFromRuleSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRuleSetFromRuleSetName', () => { + const result = client.matchRuleSetFromRuleSetName(fakePath); + assert.strictEqual(result, "ruleSetValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('synonymSet', () => { + const fakePath = "/rendered/path/synonymSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + context: "contextValue", + }; + const client = new documentserviceModule.v1.DocumentServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.synonymSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.synonymSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('synonymSetPath', () => { + const result = client.synonymSetPath("projectValue", "locationValue", "contextValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.synonymSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromSynonymSetName', () => { + const result = client.matchProjectFromSynonymSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromSynonymSetName', () => { + const result = client.matchLocationFromSynonymSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchContextFromSynonymSetName', () => { + const result = client.matchContextFromSynonymSetName(fakePath); + assert.strictEqual(result, "contextValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_rule_set_service_v1.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_rule_set_service_v1.ts new file mode 100644 index 00000000000..695a84b8fad --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_rule_set_service_v1.ts @@ -0,0 +1,1161 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 rulesetserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.RuleSetServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = rulesetserviceModule.v1.RuleSetServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = rulesetserviceModule.v1.RuleSetServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = rulesetserviceModule.v1.RuleSetServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.ruleSetServiceStub, undefined); + await client.initialize(); + assert(client.ruleSetServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.ruleSetServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.ruleSetServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + 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 rulesetserviceModule.v1.RuleSetServiceClient({ + 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('createRuleSet', () => { + it('invokes createRuleSet without error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateRuleSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.RuleSet() + ); + client.innerApiCalls.createRuleSet = stubSimpleCall(expectedResponse); + const [response] = await client.createRuleSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createRuleSet without error using callback', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateRuleSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.RuleSet() + ); + client.innerApiCalls.createRuleSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createRuleSet( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IRuleSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createRuleSet with error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateRuleSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createRuleSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createRuleSet(request), expectedError); + const actualRequest = (client.innerApiCalls.createRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createRuleSet with closed client', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateRuleSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createRuleSet(request), expectedError); + }); + }); + + describe('getRuleSet', () => { + it('invokes getRuleSet without error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.RuleSet() + ); + client.innerApiCalls.getRuleSet = stubSimpleCall(expectedResponse); + const [response] = await client.getRuleSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRuleSet without error using callback', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.RuleSet() + ); + client.innerApiCalls.getRuleSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRuleSet( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IRuleSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRuleSet with error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRuleSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getRuleSet(request), expectedError); + const actualRequest = (client.innerApiCalls.getRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRuleSet with closed client', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getRuleSet(request), expectedError); + }); + }); + + describe('updateRuleSet', () => { + it('invokes updateRuleSet without error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.RuleSet() + ); + client.innerApiCalls.updateRuleSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateRuleSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRuleSet without error using callback', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.RuleSet() + ); + client.innerApiCalls.updateRuleSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateRuleSet( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IRuleSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRuleSet with error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRuleSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateRuleSet(request), expectedError); + const actualRequest = (client.innerApiCalls.updateRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateRuleSet with closed client', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateRuleSet(request), expectedError); + }); + }); + + describe('deleteRuleSet', () => { + it('invokes deleteRuleSet without error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteRuleSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteRuleSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRuleSet without error using callback', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteRuleSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteRuleSet( + 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.deleteRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRuleSet with error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRuleSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteRuleSet(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteRuleSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteRuleSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteRuleSet with closed client', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteRuleSet(request), expectedError); + }); + }); + + describe('listRuleSets', () => { + it('invokes listRuleSets without error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + ]; + client.innerApiCalls.listRuleSets = stubSimpleCall(expectedResponse); + const [response] = await client.listRuleSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRuleSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRuleSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuleSets without error using callback', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + ]; + client.innerApiCalls.listRuleSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRuleSets( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IRuleSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listRuleSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRuleSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuleSets with error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRuleSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listRuleSets(request), expectedError); + const actualRequest = (client.innerApiCalls.listRuleSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listRuleSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listRuleSetsStream without error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + ]; + client.descriptors.page.listRuleSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listRuleSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.contentwarehouse.v1.RuleSet[] = []; + stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.RuleSet) => { + 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.listRuleSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRuleSets, request)); + assert( + (client.descriptors.page.listRuleSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listRuleSetsStream with error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRuleSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listRuleSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.contentwarehouse.v1.RuleSet[] = []; + stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.RuleSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listRuleSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listRuleSets, request)); + assert( + (client.descriptors.page.listRuleSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRuleSets without error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), + ]; + client.descriptors.page.listRuleSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.contentwarehouse.v1.IRuleSet[] = []; + const iterable = client.listRuleSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRuleSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRuleSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listRuleSets with error', async () => { + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRuleSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRuleSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.contentwarehouse.v1.IRuleSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRuleSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listRuleSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('documentLink', () => { + const fakePath = "/rendered/path/documentLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document: "documentValue", + document_link: "documentLinkValue", + }; + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.documentLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('documentLinkPath', () => { + const result = client.documentLinkPath("projectValue", "locationValue", "documentValue", "documentLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.documentLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDocumentLinkName', () => { + const result = client.matchProjectFromDocumentLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDocumentLinkName', () => { + const result = client.matchLocationFromDocumentLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromDocumentLinkName', () => { + const result = client.matchDocumentFromDocumentLinkName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentLinkFromDocumentLinkName', () => { + const result = client.matchDocumentLinkFromDocumentLinkName(fakePath); + assert.strictEqual(result, "documentLinkValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('documentSchema', () => { + const fakePath = "/rendered/path/documentSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document_schema: "documentSchemaValue", + }; + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.documentSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('documentSchemaPath', () => { + const result = client.documentSchemaPath("projectValue", "locationValue", "documentSchemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.documentSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDocumentSchemaName', () => { + const result = client.matchProjectFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDocumentSchemaName', () => { + const result = client.matchLocationFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentSchemaFromDocumentSchemaName', () => { + const result = client.matchDocumentSchemaFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "documentSchemaValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDocument', () => { + const fakePath = "/rendered/path/projectLocationDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document: "documentValue", + }; + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDocumentPath', () => { + const result = client.projectLocationDocumentPath("projectValue", "locationValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDocumentName', () => { + const result = client.matchProjectFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDocumentName', () => { + const result = client.matchLocationFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDocumentsReferenceId', () => { + const fakePath = "/rendered/path/projectLocationDocumentsReferenceId"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + reference_id: "referenceIdValue", + }; + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDocumentsReferenceIdPath', () => { + const result = client.projectLocationDocumentsReferenceIdPath("projectValue", "locationValue", "referenceIdValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchProjectFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchLocationFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceIdFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchReferenceIdFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "referenceIdValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('ruleSet', () => { + const fakePath = "/rendered/path/ruleSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + rule_set: "ruleSetValue", + }; + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.ruleSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.ruleSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('ruleSetPath', () => { + const result = client.ruleSetPath("projectValue", "locationValue", "ruleSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.ruleSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRuleSetName', () => { + const result = client.matchProjectFromRuleSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRuleSetName', () => { + const result = client.matchLocationFromRuleSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRuleSetFromRuleSetName', () => { + const result = client.matchRuleSetFromRuleSetName(fakePath); + assert.strictEqual(result, "ruleSetValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('synonymSet', () => { + const fakePath = "/rendered/path/synonymSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + context: "contextValue", + }; + const client = new rulesetserviceModule.v1.RuleSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.synonymSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.synonymSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('synonymSetPath', () => { + const result = client.synonymSetPath("projectValue", "locationValue", "contextValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.synonymSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromSynonymSetName', () => { + const result = client.matchProjectFromSynonymSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromSynonymSetName', () => { + const result = client.matchLocationFromSynonymSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchContextFromSynonymSetName', () => { + const result = client.matchContextFromSynonymSetName(fakePath); + assert.strictEqual(result, "contextValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_synonym_set_service_v1.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_synonym_set_service_v1.ts new file mode 100644 index 00000000000..bde80381fe7 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_synonym_set_service_v1.ts @@ -0,0 +1,1161 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 synonymsetserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.SynonymSetServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = synonymsetserviceModule.v1.SynonymSetServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = synonymsetserviceModule.v1.SynonymSetServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = synonymsetserviceModule.v1.SynonymSetServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.synonymSetServiceStub, undefined); + await client.initialize(); + assert(client.synonymSetServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.synonymSetServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.synonymSetServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + 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 synonymsetserviceModule.v1.SynonymSetServiceClient({ + 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('createSynonymSet', () => { + it('invokes createSynonymSet without error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SynonymSet() + ); + client.innerApiCalls.createSynonymSet = stubSimpleCall(expectedResponse); + const [response] = await client.createSynonymSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSynonymSet without error using callback', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SynonymSet() + ); + client.innerApiCalls.createSynonymSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSynonymSet( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ISynonymSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSynonymSet with error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSynonymSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createSynonymSet(request), expectedError); + const actualRequest = (client.innerApiCalls.createSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSynonymSet with closed client', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createSynonymSet(request), expectedError); + }); + }); + + describe('getSynonymSet', () => { + it('invokes getSynonymSet without error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SynonymSet() + ); + client.innerApiCalls.getSynonymSet = stubSimpleCall(expectedResponse); + const [response] = await client.getSynonymSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSynonymSet without error using callback', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SynonymSet() + ); + client.innerApiCalls.getSynonymSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSynonymSet( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ISynonymSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSynonymSet with error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSynonymSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getSynonymSet(request), expectedError); + const actualRequest = (client.innerApiCalls.getSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getSynonymSet with closed client', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.GetSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getSynonymSet(request), expectedError); + }); + }); + + describe('updateSynonymSet', () => { + it('invokes updateSynonymSet without error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SynonymSet() + ); + client.innerApiCalls.updateSynonymSet = stubSimpleCall(expectedResponse); + const [response] = await client.updateSynonymSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSynonymSet without error using callback', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.SynonymSet() + ); + client.innerApiCalls.updateSynonymSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSynonymSet( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ISynonymSet|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSynonymSet with error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSynonymSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateSynonymSet(request), expectedError); + const actualRequest = (client.innerApiCalls.updateSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateSynonymSet with closed client', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateSynonymSet(request), expectedError); + }); + }); + + describe('deleteSynonymSet', () => { + it('invokes deleteSynonymSet without error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSynonymSet = stubSimpleCall(expectedResponse); + const [response] = await client.deleteSynonymSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSynonymSet without error using callback', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSynonymSet = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSynonymSet( + 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.deleteSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSynonymSet with error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSynonymSet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteSynonymSet(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteSynonymSet as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteSynonymSet as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteSynonymSet with closed client', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteSynonymSet(request), expectedError); + }); + }); + + describe('listSynonymSets', () => { + it('invokes listSynonymSets without error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + ]; + client.innerApiCalls.listSynonymSets = stubSimpleCall(expectedResponse); + const [response] = await client.listSynonymSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSynonymSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSynonymSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSynonymSets without error using callback', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + ]; + client.innerApiCalls.listSynonymSets = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSynonymSets( + request, + (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ISynonymSet[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listSynonymSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSynonymSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSynonymSets with error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSynonymSets = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listSynonymSets(request), expectedError); + const actualRequest = (client.innerApiCalls.listSynonymSets as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listSynonymSets as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listSynonymSetsStream without error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + ]; + client.descriptors.page.listSynonymSets.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listSynonymSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.contentwarehouse.v1.SynonymSet[] = []; + stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.SynonymSet) => { + 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.listSynonymSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSynonymSets, request)); + assert( + (client.descriptors.page.listSynonymSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listSynonymSetsStream with error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSynonymSets.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listSynonymSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.contentwarehouse.v1.SynonymSet[] = []; + stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.SynonymSet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listSynonymSets.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listSynonymSets, request)); + assert( + (client.descriptors.page.listSynonymSets.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSynonymSets without error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), + ]; + client.descriptors.page.listSynonymSets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.contentwarehouse.v1.ISynonymSet[] = []; + const iterable = client.listSynonymSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSynonymSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSynonymSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listSynonymSets with error', async () => { + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSynonymSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSynonymSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.contentwarehouse.v1.ISynonymSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSynonymSets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listSynonymSets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + + describe('documentLink', () => { + const fakePath = "/rendered/path/documentLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document: "documentValue", + document_link: "documentLinkValue", + }; + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.documentLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('documentLinkPath', () => { + const result = client.documentLinkPath("projectValue", "locationValue", "documentValue", "documentLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.documentLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDocumentLinkName', () => { + const result = client.matchProjectFromDocumentLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDocumentLinkName', () => { + const result = client.matchLocationFromDocumentLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromDocumentLinkName', () => { + const result = client.matchDocumentFromDocumentLinkName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentLinkFromDocumentLinkName', () => { + const result = client.matchDocumentLinkFromDocumentLinkName(fakePath); + assert.strictEqual(result, "documentLinkValue"); + assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('documentSchema', () => { + const fakePath = "/rendered/path/documentSchema"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document_schema: "documentSchemaValue", + }; + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.documentSchemaPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.documentSchemaPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('documentSchemaPath', () => { + const result = client.documentSchemaPath("projectValue", "locationValue", "documentSchemaValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.documentSchemaPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDocumentSchemaName', () => { + const result = client.matchProjectFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDocumentSchemaName', () => { + const result = client.matchLocationFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentSchemaFromDocumentSchemaName', () => { + const result = client.matchDocumentSchemaFromDocumentSchemaName(fakePath); + assert.strictEqual(result, "documentSchemaValue"); + assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDocument', () => { + const fakePath = "/rendered/path/projectLocationDocument"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + document: "documentValue", + }; + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDocumentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDocumentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDocumentPath', () => { + const result = client.projectLocationDocumentPath("projectValue", "locationValue", "documentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDocumentName', () => { + const result = client.matchProjectFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDocumentName', () => { + const result = client.matchLocationFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDocumentFromProjectLocationDocumentName', () => { + const result = client.matchDocumentFromProjectLocationDocumentName(fakePath); + assert.strictEqual(result, "documentValue"); + assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('projectLocationDocumentsReferenceId', () => { + const fakePath = "/rendered/path/projectLocationDocumentsReferenceId"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + reference_id: "referenceIdValue", + }; + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationDocumentsReferenceIdPath', () => { + const result = client.projectLocationDocumentsReferenceIdPath("projectValue", "locationValue", "referenceIdValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchProjectFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchLocationFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchReferenceIdFromProjectLocationDocumentsReferenceIdName', () => { + const result = client.matchReferenceIdFromProjectLocationDocumentsReferenceIdName(fakePath); + assert.strictEqual(result, "referenceIdValue"); + assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('ruleSet', () => { + const fakePath = "/rendered/path/ruleSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + rule_set: "ruleSetValue", + }; + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.ruleSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.ruleSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('ruleSetPath', () => { + const result = client.ruleSetPath("projectValue", "locationValue", "ruleSetValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.ruleSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRuleSetName', () => { + const result = client.matchProjectFromRuleSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRuleSetName', () => { + const result = client.matchLocationFromRuleSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRuleSetFromRuleSetName', () => { + const result = client.matchRuleSetFromRuleSetName(fakePath); + assert.strictEqual(result, "ruleSetValue"); + assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('synonymSet', () => { + const fakePath = "/rendered/path/synonymSet"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + context: "contextValue", + }; + const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.synonymSetPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.synonymSetPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('synonymSetPath', () => { + const result = client.synonymSetPath("projectValue", "locationValue", "contextValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.synonymSetPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromSynonymSetName', () => { + const result = client.matchProjectFromSynonymSetName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromSynonymSetName', () => { + const result = client.matchLocationFromSynonymSetName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchContextFromSynonymSetName', () => { + const result = client.matchContextFromSynonymSetName(fakePath); + assert.strictEqual(result, "contextValue"); + assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/tsconfig.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/webpack.config.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/webpack.config.js new file mode 100644 index 00000000000..aa25d4769e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-contentwarehouse/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'DocumentLinkService', + filename: './document-link-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', +}; From 237e02116360ab2d70da70a9b9d33bb46d42edf2 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 13 Dec 2022 22:06:57 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../v1/.eslintignore | 7 - .../v1/.eslintrc.json | 3 - .../v1/.gitignore | 14 - .../v1/.jsdoc.js | 55 - .../v1/.mocharc.js | 33 - .../v1/.prettierrc.js | 22 - .../v1/README.md | 1 - .../v1/linkinator.config.json | 16 - .../v1/package.json | 68 - .../v1/async_document_service_request.proto | 35 - .../cloud/contentwarehouse/v1/common.proto | 140 -- .../cloud/contentwarehouse/v1/document.proto | 310 ---- .../v1/document_link_service.proto | 227 --- .../contentwarehouse/v1/document_schema.proto | 166 -- .../v1/document_schema_service.proto | 174 -- .../v1/document_service.proto | 249 --- .../v1/document_service_request.proto | 279 --- .../cloud/contentwarehouse/v1/filters.proto | 206 --- .../cloud/contentwarehouse/v1/histogram.proto | 102 -- .../contentwarehouse/v1/rule_engine.proto | 276 --- .../contentwarehouse/v1/ruleset_service.proto | 77 - .../v1/ruleset_service_request.proto | 118 -- .../contentwarehouse/v1/synonymset.proto | 58 - .../v1/synonymset_service.proto | 83 - .../v1/synonymset_service_request.proto | 122 -- .../google/cloud/documentai/v1/barcode.proto | 69 - .../google/cloud/documentai/v1/document.proto | 820 --------- .../cloud/documentai/v1/document_io.proto | 103 -- .../v1/document_processor_service.proto | 801 --------- .../cloud/documentai/v1/document_schema.proto | 141 -- .../google/cloud/documentai/v1/geometry.proto | 55 - .../documentai/v1/operation_metadata.proto | 66 - .../cloud/documentai/v1/processor.proto | 189 -- .../cloud/documentai/v1/processor_type.proto | 63 - ...ument_link_service.create_document_link.js | 74 - ...ument_link_service.delete_document_link.js | 68 - ...cument_link_service.list_linked_sources.js | 84 - ...cument_link_service.list_linked_targets.js | 68 - ...t_schema_service.create_document_schema.js | 66 - ...t_schema_service.delete_document_schema.js | 61 - ...ment_schema_service.get_document_schema.js | 61 - ...nt_schema_service.list_document_schemas.js | 78 - ...t_schema_service.update_document_schema.js | 68 - .../v1/document_service.create_document.js | 89 - .../v1/document_service.delete_document.js | 70 - .../v1/document_service.fetch_acl.js | 74 - .../v1/document_service.get_document.js | 69 - .../v1/document_service.search_documents.js | 151 -- .../generated/v1/document_service.set_acl.js | 80 - .../v1/document_service.update_document.js | 83 - .../v1/rule_set_service.create_rule_set.js | 67 - .../v1/rule_set_service.delete_rule_set.js | 63 - .../v1/rule_set_service.get_rule_set.js | 63 - .../v1/rule_set_service.list_rule_sets.js | 78 - .../v1/rule_set_service.update_rule_set.js | 68 - ...data.google.cloud.contentwarehouse.v1.json | 1231 ------------- .../synonym_set_service.create_synonym_set.js | 67 - .../synonym_set_service.delete_synonym_set.js | 63 - .../v1/synonym_set_service.get_synonym_set.js | 63 - .../synonym_set_service.list_synonym_sets.js | 78 - .../synonym_set_service.update_synonym_set.js | 68 - .../v1/src/index.ts | 33 - .../v1/src/v1/document_link_service_client.ts | 1095 ------------ .../document_link_service_client_config.json | 46 - .../v1/document_link_service_proto_list.json | 21 - .../src/v1/document_schema_service_client.ts | 1185 ------------- ...document_schema_service_client_config.json | 63 - .../document_schema_service_proto_list.json | 21 - .../v1/src/v1/document_service_client.ts | 1557 ----------------- .../v1/document_service_client_config.json | 73 - .../src/v1/document_service_proto_list.json | 21 - .../v1/src/v1/gapic_metadata.json | 359 ---- .../v1/src/v1/index.ts | 23 - .../v1/src/v1/rule_set_service_client.ts | 1144 ------------ .../v1/rule_set_service_client_config.json | 63 - .../src/v1/rule_set_service_proto_list.json | 21 - .../v1/src/v1/synonym_set_service_client.ts | 1150 ------------ .../v1/synonym_set_service_client_config.json | 63 - .../v1/synonym_set_service_proto_list.json | 21 - .../system-test/fixtures/sample/src/index.js | 31 - .../system-test/fixtures/sample/src/index.ts | 56 - .../v1/system-test/install.ts | 49 - .../v1/test/gapic_document_link_service_v1.ts | 1053 ----------- .../test/gapic_document_schema_service_v1.ts | 1199 ------------- .../v1/test/gapic_document_service_v1.ts | 1377 --------------- .../v1/test/gapic_rule_set_service_v1.ts | 1161 ------------ .../v1/test/gapic_synonym_set_service_v1.ts | 1161 ------------ .../v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../cloud/documentai/v1/document_io.proto | 12 + 90 files changed, 12 insertions(+), 21430 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/common.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_link_service.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema_service.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service_request.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/filters.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/histogram.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/rule_engine.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/barcode.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_io.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_processor_service.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_schema.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/geometry.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/operation_metadata.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor_type.proto delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.create_document_link.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.delete_document_link.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_sources.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_targets.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.create_document_schema.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.delete_document_schema.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.get_document_schema.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.list_document_schemas.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.update_document_schema.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.create_document.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.delete_document.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.fetch_acl.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.get_document.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.search_documents.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.set_acl.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.update_document.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.create_rule_set.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.delete_rule_set.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.get_rule_set.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.list_rule_sets.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.update_rule_set.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/snippet_metadata.google.cloud.contentwarehouse.v1.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.create_synonym_set.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.delete_synonym_set.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.get_synonym_set.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.list_synonym_sets.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.update_synonym_set.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_link_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_schema_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_rule_set_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_synonym_set_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-contentwarehouse/v1/webpack.config.js diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintignore b/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintrc.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.gitignore b/owl-bot-staging/google-cloud-contentwarehouse/v1/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.jsdoc.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/.jsdoc.js deleted file mode 100644 index 53260dc06f0..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/contentwarehouse', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.mocharc.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/.prettierrc.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/README.md b/owl-bot-staging/google-cloud-contentwarehouse/v1/README.md deleted file mode 100644 index 7315098501f..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Contentwarehouse: Nodejs Client diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/linkinator.config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/package.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/package.json deleted file mode 100644 index e59c6bdc1c2..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@google-cloud/contentwarehouse", - "version": "0.1.0", - "description": "Contentwarehouse client for Node.js", - "repository": "googleapis/nodejs-contentwarehouse", - "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 contentwarehouse", - "contentwarehouse", - "document link service", - "document schema service", - "document service", - "rule set service", - "synonym set service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto deleted file mode 100644 index 368ddf3f8cc..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "AsyncDocumentServiceRequestProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// Metadata object for CreateDocument request (currently empty). -message CreateDocumentMetadata { - -} - -// Metadata object for UpdateDocument request (currently empty). -message UpdateDocumentMetadata { - -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/common.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/common.proto deleted file mode 100644 index 9be7e86a34d..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/common.proto +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/resource.proto"; -import "google/protobuf/field_mask.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "CommonProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; -option (google.api.resource_definition) = { - type: "contentwarehouse.googleapis.com/Location" - pattern: "projects/{project}/locations/{location}" -}; - -// Meta information is used to improve the performance of the service. -message RequestMetadata { - // Provides user unique identification and groups information. - UserInfo user_info = 1; -} - -// Additional information returned to client, such as debugging information. -message ResponseMetadata { - // A unique id associated with this call. This id is logged for tracking - // purpose. - string request_id = 1; -} - -message UserInfo { - // A unique user identification string, as determined by the client. - // The maximum number of allowed characters is 255. - // Allowed characters include numbers 0 to 9, uppercase and lowercase letters, - // and restricted special symbols (:, @, +, -, _, ~) - // The format is "user:xxxx@example.com"; - string id = 1; - - // The unique group identifications which the user is belong to. - // The format is "group:yyyy@example.com"; - repeated string group_ids = 2; -} - -// Options for Update operations. -message UpdateOptions { - // Type for update. - UpdateType update_type = 1; - - // Field mask for merging Document fields. - // For the `FieldMask` definition, - // see - // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - google.protobuf.FieldMask update_mask = 2; - - // Options for merging. - MergeFieldsOptions merge_fields_options = 3; -} - -// Options for merging updated fields. -message MergeFieldsOptions { - // When merging message fields, the default behavior is to merge - // the content of two message fields together. If you instead want to use - // the field from the source message to replace the corresponding field in - // the destination message, set this flag to true. When this flag is set, - // specified submessage fields that are missing in source will be cleared in - // destination. - optional bool replace_message_fields = 1; - - // When merging repeated fields, the default behavior is to append - // entries from the source repeated field to the destination repeated field. - // If you instead want to keep only the entries from the source repeated - // field, set this flag to true. - // - // If you want to replace a repeated field within a message field on the - // destination message, you must set both replace_repeated_fields and - // replace_message_fields to true, otherwise the repeated fields will be - // appended. - optional bool replace_repeated_fields = 2; -} - -// Update type of the requests. -enum UpdateType { - // Defaults to full replace behavior, ie. FULL_REPLACE. - UPDATE_TYPE_UNSPECIFIED = 0; - - // Fully replace all the fields. Any field masks will be ignored. - UPDATE_TYPE_REPLACE = 1; - - // Merge the fields into the existing entities. - UPDATE_TYPE_MERGE = 2; - - // Inserts the properties by names. - UPDATE_TYPE_INSERT_PROPERTIES_BY_NAMES = 3; - - // Replace the properties by names. - UPDATE_TYPE_REPLACE_PROPERTIES_BY_NAMES = 4; - - // Delete the properties by names. - UPDATE_TYPE_DELETE_PROPERTIES_BY_NAMES = 5; -} - -// Type of database used by the customer -enum DatabaseType { - // This value is required by protobuf best practices - DB_UNKNOWN = 0; - - // Internal Spanner - DB_INFRA_SPANNER = 1; - - // Cloud Sql with a Postgres Sql instance - DB_CLOUD_SQL_POSTGRES = 2; -} - -// Access Control Mode. -enum AccessControlMode { - // This value is required by protobuf best practices - ACL_MODE_UNKNOWN = 0; - - // Universal Access: No document level access control. - ACL_MODE_UNIVERSAL_ACCESS = 1; - - // Document level access control with customer own Identity Service. - ACL_MODE_DOCUMENT_LEVEL_ACCESS_CONTROL_BYOID = 2; - - // Document level access control using Google Cloud Identity. - ACL_MODE_DOCUMENT_LEVEL_ACCESS_CONTROL_GCI = 3; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document.proto deleted file mode 100644 index 5ec6c2ec686..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document.proto +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/documentai/v1/document.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/datetime.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "DocumentProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// Defines the structure for content warehouse document proto. -message Document { - option (google.api.resource) = { - type: "contentwarehouse.googleapis.com/Document" - pattern: "projects/{project}/locations/{location}/documents/{document}" - pattern: "projects/{project}/locations/{location}/documents/referenceId/{reference_id}" - }; - - // The resource name of the document. - // Format: - // projects/{project_number}/locations/{location}/documents/{document_id}. - // - // The name is ignored when creating a document. - string name = 1; - - // The reference ID set by customers. Must be unique per project and location. - string reference_id = 11; - - // Required. Display name of the document given by the user. This name will be displayed - // in the UI. - // Customer can populate this field with the name of the document. This - // differs from the 'title' field as 'title' is optional and stores the top - // heading in the document. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Title that describes the document. - // This is usually present in the top section of the document, and is a - // mandatory field for the question-answering feature. - string title = 18; - - // Uri to display the document, for example, in the UI. - string display_uri = 17; - - // The Document schema name. - // Format: - // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. - string document_schema_name = 3 [(google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/DocumentSchema" - }]; - - oneof structured_content { - // Other document format, such as PPTX, XLXS - string plain_text = 15; - - // Document AI format to save the structured content, including OCR. - google.cloud.documentai.v1.Document cloud_ai_document = 4; - } - - // A path linked to structured content file. - string structured_content_uri = 16; - - // Raw document file. - oneof raw_document { - // Raw document file in Cloud Storage path. - string raw_document_path = 5; - - // Raw document content. - bytes inline_raw_document = 6; - } - - // List of values that are user supplied metadata. - repeated Property properties = 7; - - // Output only. The time when the document is last updated. - google.protobuf.Timestamp update_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the document is created. - google.protobuf.Timestamp create_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // This is used when DocAI was not used to load the document and parsing/ - // extracting is needed for the inline_raw_document. For example, if - // inline_raw_document is the byte representation of a PDF file, then - // this should be set to: RAW_DOCUMENT_FILE_TYPE_PDF. - RawDocumentFileType raw_document_file_type = 10; - - // If true, makes the document visible to asynchronous policies and rules. - bool async_enabled = 12; - - // If true, text extraction will not be performed. - bool text_extraction_disabled = 19; - - // The user who creates the document. - string creator = 13; - - // The user who lastly updates the document. - string updater = 14; -} - -// References to the documents. -message DocumentReference { - // Required. Name of the referenced document. - string document_name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Document" - } - ]; - - // display_name of the referenced document; this name does not need to be - // consistent to the display_name in the Document proto, depending on the ACL - // constraint. - string display_name = 2; - - // Stores the subset of the referenced document's content. - // This is useful to allow user peek the information of the referenced - // document. - string snippet = 3; - - // The document type of the document being referenced. - bool document_is_folder = 4; - - // Output only. The time when the document is last updated. - google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the document is created. - google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the document is deleted. - google.protobuf.Timestamp delete_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Property of a document. -message Property { - // Required. Must match the name of a PropertyDefinition in the DocumentSchema. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Type of the property. - // Must match the property_options type of the matching PropertyDefinition. - // Value of the Property parsed into a specific data type. - // Specific type value(s) obtained from Document AIs Property.mention_text - // field. - oneof values { - // Integer property values. - IntegerArray integer_values = 2; - - // Float property values. - FloatArray float_values = 3; - - // String/text property values. - TextArray text_values = 4; - - // Enum property values. - EnumArray enum_values = 5; - - // Nested structured data property values. - PropertyArray property_values = 6; - - // Date time property values. - // It is not supported by CMEK compliant deployment. - DateTimeArray date_time_values = 7; - - // Map property values. - MapProperty map_property = 8; - - // Timestamp property values. - // It is not supported by CMEK compliant deployment. - TimestampArray timestamp_values = 9; - } -} - -// Integer values. -message IntegerArray { - // List of integer values. - repeated int32 values = 1; -} - -// Float values. -message FloatArray { - // List of float values. - repeated float values = 1; -} - -// String/text values. -message TextArray { - // List of text values. - repeated string values = 1; -} - -// Enum values. -message EnumArray { - // List of enum values. - repeated string values = 1; -} - -// DateTime values. -message DateTimeArray { - // List of datetime values. - // Both OffsetDateTime and ZonedDateTime are supported. - repeated google.type.DateTime values = 1; -} - -// Timestamp values. -message TimestampArray { - // List of timestamp values. - repeated TimestampValue values = 1; -} - -// Timestamp value type. -message TimestampValue { - oneof value { - // Timestamp value - google.protobuf.Timestamp timestamp_value = 1; - - // The string must represent a valid instant in UTC and is parsed using - // java.time.format.DateTimeFormatter.ISO_INSTANT. - // e.g. "2013-09-29T18:46:19Z" - string text_value = 2; - } -} - -// Property values. -message PropertyArray { - // List of property values. - repeated Property properties = 1; -} - -// Map property value. -// Represents a structured entries of key value pairs, consisting of field names -// which map to dynamically typed values. -message MapProperty { - // Unordered map of dynamically typed values. - map fields = 1; -} - -// `Value` represents a dynamically typed value which can be either be -// a float, a integer, a string, or a datetime value. A producer of value is -// expected to set one of these variants. Absence of any variant indicates an -// error. -message Value { - // The kind of value. - oneof kind { - // Represents a float value. - float float_value = 1; - - // Represents a integer value. - int32 int_value = 2; - - // Represents a string value. - string string_value = 3; - - // Represents an enum value. - EnumValue enum_value = 4; - - // Represents a datetime value. - google.type.DateTime datetime_value = 5; - - // Represents a timestamp value. - TimestampValue timestamp_value = 6; - - // Represents a boolean value. - bool boolean_value = 7; - } -} - -// Represents the string value of the enum field. -message EnumValue { - // String value of the enum field. This must match defined set of enums - // in document schema using EnumTypeOptions. - string value = 1; -} - -// When a raw document is supplied, this indicates the file format -enum RawDocumentFileType { - // No raw document specified or it is non-parsable - RAW_DOCUMENT_FILE_TYPE_UNSPECIFIED = 0; - - // Adobe PDF format - RAW_DOCUMENT_FILE_TYPE_PDF = 1; - - // Microsoft Word format - RAW_DOCUMENT_FILE_TYPE_DOCX = 2; - - // Microsoft Excel format - RAW_DOCUMENT_FILE_TYPE_XLSX = 3; - - // Microsoft Powerpoint format - RAW_DOCUMENT_FILE_TYPE_PPTX = 4; - - // UTF-8 encoded text format - RAW_DOCUMENT_FILE_TYPE_TEXT = 5; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_link_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_link_service.proto deleted file mode 100644 index a5a14d8dcbf..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_link_service.proto +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/contentwarehouse/v1/common.proto"; -import "google/cloud/contentwarehouse/v1/document.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "DocumentLinkServiceProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// This service lets you manage document-links. -// Document-Links are treated as sub-resources under source documents. -service DocumentLinkService { - option (google.api.default_host) = "contentwarehouse.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Return all target document-links from the document. - rpc ListLinkedTargets(ListLinkedTargetsRequest) returns (ListLinkedTargetsResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/documents/*}/linkedTargets" - body: "*" - }; - option (google.api.method_signature) = "parent"; - } - - // Return all source document-links from the document. - rpc ListLinkedSources(ListLinkedSourcesRequest) returns (ListLinkedSourcesResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/documents/*}/linkedSources" - body: "*" - }; - option (google.api.method_signature) = "parent"; - } - - // Create a link between a source document and a target document. - rpc CreateDocumentLink(CreateDocumentLinkRequest) returns (DocumentLink) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/documents/*}/documentLinks" - body: "*" - }; - option (google.api.method_signature) = "parent,document_link"; - } - - // Remove the link between the source and target documents. - rpc DeleteDocumentLink(DeleteDocumentLinkRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/documents/*/documentLinks/*}:delete" - body: "*" - }; - option (google.api.method_signature) = "name"; - } -} - -// Response message for DocumentLinkService.ListLinkedTargets. -message ListLinkedTargetsResponse { - // Target document-links. - repeated DocumentLink document_links = 1; - - // A token, which can be sent as `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 DocumentLinkService.ListLinkedTargets. -message ListLinkedTargetsRequest { - // Required. The name of the document, for which all target links are returned. - // Format: - // projects/{project_number}/locations/{location}/documents/{target_document_id}. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Document" - } - ]; - - // The meta information collected about the document creator, used to enforce - // access control for the service. - RequestMetadata request_metadata = 2; -} - -// Response message for DocumentLinkService.ListLinkedSources. -message ListLinkedSourcesResponse { - // Source document-links. - repeated DocumentLink document_links = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} - -// Response message for DocumentLinkService.ListLinkedSources. -message ListLinkedSourcesRequest { - // Required. The name of the document, for which all source links are returned. - // Format: - // projects/{project_number}/locations/{location}/documents/{source_document_id}. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Document" - } - ]; - - // The maximum number of document-links to return. The service may return - // fewer than this value. - // - // If unspecified, at most 50 document-links will be returned. - // The maximum value is 1000; values above 1000 will be coerced to 1000. - int32 page_size = 3; - - // A page token, received from a previous `ListLinkedSources` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListLinkedSources` - // must match the call that provided the page token. - string page_token = 4; - - // The meta information collected about the document creator, used to enforce - // access control for the service. - RequestMetadata request_metadata = 2; -} - -// A document-link between source and target document. -message DocumentLink { - option (google.api.resource) = { - type: "contentwarehouse.googleapis.com/DocumentLink" - pattern: "projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}" - }; - - // The state of a document-link. - enum State { - // Unknown state of documentlink. - STATE_UNSPECIFIED = 0; - - // The documentlink has both source and target documents detected. - ACTIVE = 1; - - // Target document is deleted, and mark the documentlink as soft-deleted. - SOFT_DELETED = 2; - } - - // Name of this document-link. - // It is required that the parent derived form the name to be consistent with - // the source document reference. Otherwise an exception will be thrown. - // Format: - // projects/{project_number}/locations/{location}/documents/{source_document_id}/documentLinks/{document_link_id}. - string name = 1; - - // Document references of the source document. - DocumentReference source_document_reference = 2; - - // Document references of the target document. - DocumentReference target_document_reference = 3; - - // Description of this document-link. - string description = 4; - - // Output only. The time when the documentLink is last updated. - google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the documentLink is created. - google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The state of the documentlink. If target node has been deleted, the - // link is marked as invalid. Removing a source node will result in removal - // of all associated links. - State state = 7; -} - -// Request message for DocumentLinkService.CreateDocumentLink. -message CreateDocumentLinkRequest { - // Required. Parent of the document-link to be created. - // parent of document-link should be a document. - // Format: - // projects/{project_number}/locations/{location}/documents/{source_document_id}. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Document" - } - ]; - - // Required. Document links associated with the source documents (source_document_id). - DocumentLink document_link = 2 [(google.api.field_behavior) = REQUIRED]; - - // The meta information collected about the document creator, used to enforce - // access control for the service. - RequestMetadata request_metadata = 3; -} - -// Request message for DocumentLinkService.DeleteDocumentLink. -message DeleteDocumentLinkRequest { - // Required. The name of the document-link to be deleted. - // Format: - // projects/{project_number}/locations/{location}/documents/{source_document_id}/documentLinks/{document_link_id}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/DocumentLink" - } - ]; - - // The meta information collected about the document creator, used to enforce - // access control for the service. - RequestMetadata request_metadata = 2; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema.proto deleted file mode 100644 index fae52e4c51e..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema.proto +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "DocumentSchemaProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// A document schema used to define document structure. -message DocumentSchema { - option (google.api.resource) = { - type: "contentwarehouse.googleapis.com/DocumentSchema" - pattern: "projects/{project}/locations/{location}/documentSchemas/{document_schema}" - }; - - // The resource name of the document schema. - // Format: - // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. - // - // The name is ignored when creating a document schema. - string name = 1; - - // Required. Name of the schema given by the user. Must be unique per customer. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Document details. - repeated PropertyDefinition property_definitions = 3; - - // Document Type, true refers the document is a folder, otherwise it is - // a typical document. - bool document_is_folder = 4; - - // Output only. The time when the document schema is last updated. - google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time when the document schema is created. - google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Schema description. - string description = 7; -} - -// Defines the metadata for a schema property. -message PropertyDefinition { - // Required. The name of the metadata property. - // Must be unique within a document schema and is case insensitive. - // Names must be non-blank, start with a letter, and can contain alphanumeric - // characters and: /, :, -, _, and . - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // The display-name for the property, used for front-end. - string display_name = 12; - - // Whether the property can have multiple values. - bool is_repeatable = 2; - - // Whether the property can be filtered. If this is a sub-property, all the - // parent properties must be marked filterable. - bool is_filterable = 3; - - // Indicates that the property should be included in a global search. - bool is_searchable = 4; - - // Whether the property is user supplied metadata. - bool is_metadata = 5; - - // Whether the property is mandatory. - // Default is 'false', i.e. populating property value can be skipped. - // If 'true' then user must populate the value for this property. - bool is_required = 14; - - // Type of the property. - oneof value_type_options { - // Integer property. - IntegerTypeOptions integer_type_options = 7; - - // Float property. - FloatTypeOptions float_type_options = 8; - - // Text/string property. - TextTypeOptions text_type_options = 9; - - // Nested structured data property. - PropertyTypeOptions property_type_options = 10; - - // Enum/categorical property. - EnumTypeOptions enum_type_options = 11; - - // Date time property. - // It is not supported by CMEK compliant deployment. - DateTimeTypeOptions date_time_type_options = 13; - - // Map property. - MapTypeOptions map_type_options = 15; - - // Timestamp property. - // It is not supported by CMEK compliant deployment. - TimestampTypeOptions timestamp_type_options = 16; - } -} - -// Configurations for an integer property. -message IntegerTypeOptions { - -} - -// Configurations for a float property. -message FloatTypeOptions { - -} - -// Configurations for a text property. -message TextTypeOptions { - -} - -// Configurations for a date time property. -message DateTimeTypeOptions { - -} - -// Configurations for a Map property. -message MapTypeOptions { - -} - -// Configurations for a timestamp property. -message TimestampTypeOptions { - -} - -// Configurations for a nested structured data property. -message PropertyTypeOptions { - // Required. List of property definitions. - repeated PropertyDefinition property_definitions = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Configurations for an enum/categorical property. -message EnumTypeOptions { - // Required. List of possible enum values. - repeated string possible_values = 1 [(google.api.field_behavior) = REQUIRED]; - - // Make sure the Enum property value provided in the document is in the - // possile value list during document creation. The validation check runs by - // default. - bool validation_check_disabled = 2; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema_service.proto deleted file mode 100644 index 9c570695045..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_schema_service.proto +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/contentwarehouse/v1/document_schema.proto"; -import "google/protobuf/empty.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "DocumentSchemaServiceProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// (go/id-aip-list) to add a finite deadline and enable fail_fast. - -// This service lets you manage document schema. -service DocumentSchemaService { - option (google.api.default_host) = "contentwarehouse.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a document schema. - rpc CreateDocumentSchema(CreateDocumentSchemaRequest) returns (DocumentSchema) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/documentSchemas" - body: "document_schema" - }; - option (google.api.method_signature) = "parent,document_schema"; - } - - // Updates a Document Schema. Returns INVALID_ARGUMENT if the name of the - // Document Schema is non-empty and does not equal the existing name. - // Supports only appending new properties, adding new ENUM possible values, - // and updating the [EnumTypeOptions.validation_check_disabled][google.cloud.contentwarehouse.v1.EnumTypeOptions.validation_check_disabled] flag for - // ENUM possible values. Updating existing properties will result into - // INVALID_ARGUMENT. - rpc UpdateDocumentSchema(UpdateDocumentSchemaRequest) returns (DocumentSchema) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/documentSchemas/*}" - body: "*" - }; - option (google.api.method_signature) = "name,document_schema"; - } - - // Gets a document schema. Returns NOT_FOUND if the document schema does not - // exist. - rpc GetDocumentSchema(GetDocumentSchemaRequest) returns (DocumentSchema) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/documentSchemas/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes a document schema. Returns NOT_FOUND if the document schema does - // not exist. Returns BAD_REQUEST if the document schema has documents - // depending on it. - rpc DeleteDocumentSchema(DeleteDocumentSchemaRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/documentSchemas/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists document schemas. - rpc ListDocumentSchemas(ListDocumentSchemasRequest) returns (ListDocumentSchemasResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/documentSchemas" - }; - option (google.api.method_signature) = "parent"; - } -} - -// Request message for DocumentSchemaService.CreateDocumentSchema. -message CreateDocumentSchemaRequest { - // Required. The parent name. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Location" - } - ]; - - // Required. The document schema to create. - DocumentSchema document_schema = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for DocumentSchemaService.GetDocumentSchema. -message GetDocumentSchemaRequest { - // Required. The name of the document schema to retrieve. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/DocumentSchema" - } - ]; -} - -// Request message for DocumentSchemaService.UpdateDocumentSchema. -message UpdateDocumentSchemaRequest { - // Required. The name of the document schema to update. - // Format: - // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/DocumentSchema" - } - ]; - - // Required. The document schema to update with. - DocumentSchema document_schema = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for DocumentSchemaService.DeleteDocumentSchema. -message DeleteDocumentSchemaRequest { - // Required. The name of the document schema to delete. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/DocumentSchema" - } - ]; -} - -// Request message for DocumentSchemaService.ListDocumentSchemas. -message ListDocumentSchemasRequest { - // Required. The parent, which owns this collection of document schemas. - // Format: projects/{project_number}/locations/{location}. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Location" - } - ]; - - // The maximum number of document schemas to return. The service may return - // fewer than this value. - // If unspecified, at most 50 document schemas will be returned. - // The maximum value is 1000; values above 1000 will be coerced to 1000. - int32 page_size = 2; - - // A page token, received from a previous `ListDocumentSchemas` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListDocumentSchemas` - // must match the call that provided the page token. - string page_token = 3; -} - -// Response message for DocumentSchemaService.ListDocumentSchemas. -message ListDocumentSchemasResponse { - // The document schemas from the specified parent. - repeated DocumentSchema document_schemas = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service.proto deleted file mode 100644 index e0c1c875088..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service.proto +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/resource.proto"; -import "google/cloud/contentwarehouse/v1/common.proto"; -import "google/cloud/contentwarehouse/v1/document.proto"; -import "google/cloud/contentwarehouse/v1/document_service_request.proto"; -import "google/cloud/contentwarehouse/v1/histogram.proto"; -import "google/cloud/contentwarehouse/v1/rule_engine.proto"; -import "google/iam/v1/policy.proto"; -import "google/protobuf/empty.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "DocumentServiceProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// This service lets you manage document. -service DocumentService { - option (google.api.default_host) = "contentwarehouse.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a document. - rpc CreateDocument(CreateDocumentRequest) returns (CreateDocumentResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/documents" - body: "*" - }; - option (google.api.method_signature) = "parent,document"; - } - - // Gets a document. Returns NOT_FOUND if the document does not exist. - rpc GetDocument(GetDocumentRequest) returns (Document) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/documents/*}:get" - body: "*" - additional_bindings { - post: "/v1/{name=projects/*/locations/*/documents/referenceId/*}:get" - body: "*" - } - }; - option (google.api.method_signature) = "name"; - } - - // Updates a document. Returns INVALID_ARGUMENT if the name of the document - // is non-empty and does not equal the existing name. - rpc UpdateDocument(UpdateDocumentRequest) returns (UpdateDocumentResponse) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/documents/*}" - body: "*" - additional_bindings { - patch: "/v1/{name=projects/*/locations/*/documents/referenceId/*}" - body: "*" - } - }; - option (google.api.method_signature) = "name,document"; - } - - // Deletes a document. Returns NOT_FOUND if the document does not exist. - rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/documents/*}:delete" - body: "*" - additional_bindings { - post: "/v1/{name=projects/*/locations/*/documents/referenceId/*}:delete" - body: "*" - } - }; - option (google.api.method_signature) = "name"; - } - - // Searches for documents using provided [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. - // This call only returns documents that the caller has permission to search - // against. - rpc SearchDocuments(SearchDocumentsRequest) returns (SearchDocumentsResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/documents:search" - body: "*" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets the access control policy for a resource. Returns NOT_FOUND error if - // the resource does not exist. Returns an empty policy if the resource exists - // but does not have a policy set. - rpc FetchAcl(FetchAclRequest) returns (FetchAclResponse) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/locations/*/documents/*}:fetchAcl" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*}:fetchAcl" - body: "*" - } - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy for a resource. Replaces any existing - // policy. - rpc SetAcl(SetAclRequest) returns (SetAclResponse) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/locations/*/documents/*}:setAcl" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*}:setAcl" - body: "*" - } - }; - option (google.api.method_signature) = "resource,policy"; - } -} - -// Response message for DocumentService.CreateDocument. -message CreateDocumentResponse { - // Document created after executing create request. - Document document = 1; - - // Output from Rule Engine recording the rule evaluator and action executor's - // output. - // - // Refer format in: google/cloud/contentwarehouse/v1/rule_engine.proto - RuleEngineOutput rule_engine_output = 2; - - // Additional information for the API invocation, such as the request tracking - // id. - ResponseMetadata metadata = 3; -} - -// Response message for DocumentService.UpdateDocument. -message UpdateDocumentResponse { - // Updated document after executing update request. - Document document = 1; - - // Output from Rule Engine recording the rule evaluator and action executor's - // output. - // - // Refer format in: google/cloud/contentwarehouse/v1/rule_engine.proto - RuleEngineOutput rule_engine_output = 2; - - // Additional information for the API invocation, such as the request tracking - // id. - ResponseMetadata metadata = 3; -} - -// Additional result info for the question-answering feature. -message QAResult { - // A text span in the search text snippet that represents a highlighted - // section (answer context, highly relevant sentence, etc.). - message Highlight { - // Start index of the highlight. - int32 start_index = 1; - - // End index of the highlight, exclusive. - int32 end_index = 2; - } - - // Highlighted sections in the snippet. - repeated Highlight highlights = 1; - - // The calibrated confidence score for this document, in the range - // [0., 1.]. This represents the confidence level for whether the returned - // document and snippet answers the user's query. - float confidence_score = 2; -} - -// Response message for DocumentService.SearchDocuments. -message SearchDocumentsResponse { - // Document entry with metadata inside [SearchDocumentsResponse][google.cloud.contentwarehouse.v1.SearchDocumentsResponse] - message MatchingDocument { - // Document that matches the specified [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. - // This document only contains indexed metadata information. - Document document = 1; - - // Contains snippets of text from the document full raw text that most - // closely match a search query's keywords, if available. All HTML tags in - // the original fields are stripped when returned in this field, and - // matching query keywords are enclosed in HTML bold tags. - // - // If the question-answering feature is enabled, this field will instead - // contain a snippet that answers the user's natural-language query. No HTML - // bold tags will be present, and highlights in the answer snippet can be - // found in [QAResult.highlights][google.cloud.contentwarehouse.v1.QAResult.highlights]. - string search_text_snippet = 2; - - // Experimental. - // Additional result info if the question-answering feature is enabled. - QAResult qa_result = 3; - } - - // The document entities that match the specified [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. - repeated MatchingDocument matching_documents = 1; - - // The token that specifies the starting position of the next page of results. - // This field is empty if there are no more results. - string next_page_token = 2; - - // The total number of matched documents which is available only if the client - // set [SearchDocumentsRequest.require_total_size][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.require_total_size] to `true`. Otherwise, the - // value will be `-1`. `total_size` will max at "100,000". If this - // is returned, then it can be assumed that the count is equal to or greater - // than 100,000. Typically a UI would handle this condition by displaying - // "of many", for example: "Displaying 10 of many". - int32 total_size = 3; - - // Additional information for the API invocation, such as the request tracking - // id. - ResponseMetadata metadata = 4; - - // The histogram results that match with the specified - // [SearchDocumentsRequest.histogram_queries][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.histogram_queries]. - repeated HistogramQueryResult histogram_query_results = 6; -} - -// Response message for DocumentService.FetchAcl. -message FetchAclResponse { - // The IAM policy. - google.iam.v1.Policy policy = 1; - - // Additional information for the API invocation, such as the request tracking - // id. - ResponseMetadata metadata = 2; -} - -// Response message for DocumentService.SetAcl. -message SetAclResponse { - // The policy will be attached to a resource (e.g. projecct, document). - google.iam.v1.Policy policy = 1; - - // Additional information for the API invocation, such as the request tracking - // id. - ResponseMetadata metadata = 2; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service_request.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service_request.proto deleted file mode 100644 index 635bfdb6558..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/document_service_request.proto +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/contentwarehouse/v1/common.proto"; -import "google/cloud/contentwarehouse/v1/document.proto"; -import "google/cloud/contentwarehouse/v1/filters.proto"; -import "google/cloud/contentwarehouse/v1/histogram.proto"; -import "google/iam/v1/policy.proto"; -import "google/protobuf/field_mask.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "DocumentServiceRequestProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// Request Option for processing Cloud AI Document in CW Document. -message CloudAIDocumentOption { - // Whether to convert all the entities to properties. - bool enable_entities_conversions = 1; - - // If set, only selected entities will be converted to properties. - map customized_entities_properties_conversions = 2; -} - -// Request message for DocumentService.CreateDocument. -message CreateDocumentRequest { - // Required. The parent name. - // Format: projects/{project_number}/locations/{location}. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Location" - } - ]; - - // Required. The document to create. - Document document = 2 [(google.api.field_behavior) = REQUIRED]; - - // The meta information collected about the end user, used to enforce access - // control for the service. - RequestMetadata request_metadata = 3; - - // Default document policy during creation. Conditions defined in the policy - // will be ignored. - google.iam.v1.Policy policy = 4; - - // Request Option for processing Cloud AI Document in CW Document. - CloudAIDocumentOption cloud_ai_document_option = 5; - - // Field mask for creating Document fields. If mask path is empty, - // it means all fields are masked. - // For the `FieldMask` definition, - // see - // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - google.protobuf.FieldMask create_mask = 6; -} - -// Request message for DocumentService.GetDocument. -message GetDocumentRequest { - // Required. The name of the document to retrieve. - // Format: - // projects/{project_number}/locations/{location}/documents/{document_id} or - // projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Document" - } - ]; - - // The meta information collected about the end user, used to enforce access - // control for the service. - RequestMetadata request_metadata = 2; -} - -// Request message for DocumentService.UpdateDocument. -message UpdateDocumentRequest { - // Required. The name of the document to update. - // Format: - // projects/{project_number}/locations/{location}/documents/{document_id} - // or - // projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Document" - } - ]; - - // Required. The document to update. - Document document = 2 [(google.api.field_behavior) = REQUIRED]; - - // The meta information collected about the end user, used to enforce access - // control for the service. - RequestMetadata request_metadata = 3; - - // Request Option for processing Cloud AI Document in CW Document. - CloudAIDocumentOption cloud_ai_document_option = 5; - - // Options for the update operation. - UpdateOptions update_options = 6; -} - -// Request message for DocumentService.DeleteDocument. -message DeleteDocumentRequest { - // Required. The name of the document to delete. - // Format: - // projects/{project_number}/locations/{location}/documents/{document_id} - // or - // projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Document" - } - ]; - - // The meta information collected about the end user, used to enforce access - // control for the service. - RequestMetadata request_metadata = 2; -} - -// Request message for DocumentService.SearchDocuments. -message SearchDocumentsRequest { - // Required. The parent, which owns this collection of documents. - // Format: projects/{project_number}/locations/{location}. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Location" - } - ]; - - // The meta information collected about the end user, used to enforce access - // control and improve the search quality of the service. - RequestMetadata request_metadata = 3; - - // Query used to search against documents (keyword, filters, etc.). - DocumentQuery document_query = 4; - - // An integer that specifies the current offset (that is, starting result - // location, amongst the documents deemed by the API as relevant) in search - // results. This field is only considered if [page_token][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.page_token] is unset. - // - // The maximum allowed value is 5000. Otherwise an error is thrown. - // - // For example, 0 means to return results starting from the first matching - // document, and 10 means to return from the 11th document. This can be used - // for pagination, (for example, pageSize = 10 and offset = 10 means to return - // from the second page). - int32 offset = 5; - - // A limit on the number of documents returned in the search results. - // Increasing this value above the default value of 10 can increase search - // response time. The value can be between 1 and 100. - int32 page_size = 6; - - // The token specifying the current offset within search results. - // See [SearchDocumentsResponse.next_page_token][google.cloud.contentwarehouse.v1.SearchDocumentsResponse.next_page_token] for an explanation of how - // to obtain the next set of query results. - string page_token = 7; - - // The criteria determining how search results are sorted. For non-empty - // query, default is `"relevance desc"`. For empty query, default is - // `"upload_date desc"`. - // - // Supported options are: - // - // * `"relevance desc"`: By relevance descending, as determined by the API - // algorithms. - // * `"upload_date desc"`: By upload date descending. - // * `"upload_date"`: By upload date ascending. - // * `"update_date desc"`: By last updated date descending. - // * `"update_date"`: By last updated date ascending. - string order_by = 8; - - // An expression specifying a histogram request against matching - // documents. Expression syntax is an aggregation function call with - // histogram facets and other options. - // - // The following aggregation functions are supported: - // - // * `count(string_histogram_facet)`: Count the number of matching entities - // for each distinct attribute value. - // - // Data types: - // - // * Histogram facet (aka filterable properties): Facet names with format - // <schema id>.<facet>. Facets will have the - // format of: `[a-zA-Z][a-zA-Z0-9_:/-.]`. If the facet is a child - // facet, then the parent hierarchy needs to be specified separated by - // dots in the prefix after the schema id. Thus, the format for a multi- - // level facet is: <schema id>.<parent facet name>. - // <child facet name>. Example: - // schema123.root_parent_facet.middle_facet.child_facet - // * DocumentSchemaId: (with no schema id prefix) to get - // histograms for each document type (returns the schema id path, e.g. - // projects/12345/locations/us-west/documentSchemas/abc123). - // - // Example expression: - // - // * Document type counts: - // count('DocumentSchemaId') - // - // * For schema id, abc123, get the counts for MORTGAGE_TYPE: - // count('abc123.MORTGAGE_TYPE') - repeated HistogramQuery histogram_queries = 9; - - // Optional. Controls if the search document request requires the return of a total size - // of matched documents. See [SearchDocumentsResponse.total_size][google.cloud.contentwarehouse.v1.SearchDocumentsResponse.total_size]. - // - // Enabling this flag may adversely impact performance. Hint: If this is - // used with pagination, set this flag on the initial query but set this - // to false on subsequent page calls (keep the total count locally). - // - // Defaults to false. - bool require_total_size = 10; - - // Experimental, do not use. - // The limit on the number of documents returned for the question-answering - // feature. To enable the question-answering feature, set - // [DocumentQuery].[is_nl_query][] to true. - int32 qa_size_limit = 11; -} - -// Request message for DocumentService.FetchAcl -message FetchAclRequest { - // Required. REQUIRED: The resource for which the policy is being requested. - // Format for document: - // projects/{project_number}/locations/{location}/documents/{document_id}. - // Format for project: projects/{project_number}. - string resource = 1 [(google.api.field_behavior) = REQUIRED]; - - // The meta information collected about the end user, used to enforce access - // control for the service. - RequestMetadata request_metadata = 2; - - // For Get Project ACL only. Authorization check for end user will be ignored - // when project_owner=true. - bool project_owner = 3; -} - -// Request message for DocumentService.SetAcl. -message SetAclRequest { - // Required. REQUIRED: The resource for which the policy is being requested. - // Format for document: - // projects/{project_number}/locations/{location}/documents/{document_id}. - // Format for project: projects/{project_number}. - string resource = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. REQUIRED: The complete policy to be applied to the `resource`. The size of - // the policy is limited to a few 10s of KB. - google.iam.v1.Policy policy = 2 [(google.api.field_behavior) = REQUIRED]; - - // The meta information collected about the end user, used to enforce access - // control for the service. - RequestMetadata request_metadata = 3; - - // For Set Project ACL only. Authorization check for end user will be ignored - // when project_owner=true. - bool project_owner = 4; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/filters.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/filters.proto deleted file mode 100644 index 52e39ca90a2..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/filters.proto +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/resource.proto"; -import "google/type/interval.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "FiltersProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -message DocumentQuery { - // The query string that matches against the full text of the document and - // the searchable properties. - // The maximum number of allowed characters is 255. - string query = 1; - - // Experimental, do not use. - // If the query is a natural language question. False by default. If true, - // then the question-answering feature will be used instead of search, and - // `result_count` in [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest] must be set. In addition, all - // other input fields related to search (pagination, histograms, etc.) will be - // ignored. - bool is_nl_query = 12; - - // This filter specifies a structured syntax to match against the - // [PropertyDefinition].[is_filterable][] marked as `true`. The syntax for - // this expression is a subset of SQL syntax. - // - // Supported operators are: `=`, `!=`, `<`, `<=`, `>`, and `>=` where the left - // of the operator is a property name and the right of the operator is a - // number or a quoted string. You must escape backslash (\\) and quote (\") - // characters. Supported functions are `LOWER([property_name])` to perform a - // case insensitive match and `EMPTY([property_name])` to filter on the - // existence of a key. - // - // Boolean expressions (AND/OR/NOT) are supported up to 3 levels of nesting - // (for example, "((A AND B AND C) OR NOT D) AND E"), a maximum of 100 - // comparisons or functions are allowed in the expression. The expression must - // be < 6000 bytes in length. - // - // Sample Query: - // `(LOWER(driving_license)="class \"a\"" OR EMPTY(driving_license)) AND - // driving_years > 10` - string custom_property_filter = 4 [deprecated = true]; - - // Documents created/updated within a range specified by this filter are - // searched against. - repeated TimeFilter time_filters = 5; - - // This filter specifies the exact document schema - // [Document.document_schema_name][google.cloud.contentwarehouse.v1.Document.document_schema_name] of the documents to search against. - // - // If a value isn't specified, documents within the search results are - // associated with any schema. If multiple values are specified, documents - // within the search results may be associated with any of the specified - // schemas. - // - // At most 20 document schema names are allowed. - repeated string document_schema_names = 6; - - // This filter specifies a structured syntax to match against the - // [PropertyDefinition.is_filterable][google.cloud.contentwarehouse.v1.PropertyDefinition.is_filterable] marked as `true`. The relationship - // between the PropertyFilters is OR. - repeated PropertyFilter property_filter = 7; - - // This filter specifies the types of files to return: ALL, FOLDER, or FILE. - // If FOLDER or FILE is specified, then only either folders or files will be - // returned, respectively. If ALL is specified, both folders and files will be - // returned. - // - // If no value is specified, ALL files will be returned. - FileTypeFilter file_type_filter = 8; - - // Search all the documents under this specified folder. - // Format: - // projects/{project_number}/locations/{location}/documents/{document_id}. - string folder_name_filter = 9; - - // For custom synonyms. - // Customers provide the synonyms based on context. One customer can provide - // multiple set of synonyms based on different context. The search query will - // be expanded based on the custom synonyms of the query context set. - // By default, no custom synonyms wll be applied if no query context is - // provided. - // It is not supported for CMEK compliant deployment. - repeated string query_context = 10; - - // The exact creator(s) of the documents to search against. - // - // If a value isn't specified, documents within the search results are - // associated with any creator. If multiple values are specified, documents - // within the search results may be associated with any of the specified - // creators. - repeated string document_creator_filter = 11; -} - -// Filter on create timestamp or update timestamp of documents. -message TimeFilter { - // Time field used in TimeFilter. - enum TimeField { - // Default value. - TIME_FIELD_UNSPECIFIED = 0; - - // Earliest document create time. - CREATE_TIME = 1; - - // Latest document update time. - UPDATE_TIME = 2; - } - - google.type.Interval time_range = 1; - - // Specifies which time field to filter documents on. - // - // Defaults to [TimeField.UPLOAD_TIME][]. - TimeField time_field = 2; -} - -message PropertyFilter { - // The Document schema name [Document.document_schema_name][google.cloud.contentwarehouse.v1.Document.document_schema_name]. - // Format: - // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. - string document_schema_name = 1 [(google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/DocumentSchema" - }]; - - // The filter condition. - // The syntax for this expression is a subset of SQL syntax. - // - // Supported operators are: `=`, `!=`, `<`, `<=`, `>`, `>=`, and `~~` where - // the left of the operator is a property name and the right of the operator - // is a number or a quoted string. You must escape backslash (\\) and quote - // (\") characters. - // - // `~~` is the LIKE operator. The right of the operator must be a string. The - // only supported property data type for LIKE is text_values. It provides - // semantic search functionality by parsing, stemming and doing synonyms - // expansion against the input query. It matches if the property contains - // semantic similar content to the query. It is not regex matching or wildcard - // matching. For example, "property.company ~~ \"google\"" will match records - // whose property `property.compnay` have values like "Google Inc.", "Google - // LLC" or "Google Company". - // - // Supported functions are `LOWER([property_name])` to perform a - // case insensitive match and `EMPTY([property_name])` to filter on the - // existence of a key. - // - // Boolean expressions (AND/OR/NOT) are supported up to 3 levels of nesting - // (for example, "((A AND B AND C) OR NOT D) AND E"), a maximum of 100 - // comparisons or functions are allowed in the expression. The expression must - // be < 6000 bytes in length. - // - // Only properties that are marked filterable are allowed - // ([PropertyDefinition.is_filterable][google.cloud.contentwarehouse.v1.PropertyDefinition.is_filterable]). Property names do not need to be - // prefixed by the document schema id (as is the case with histograms), - // however property names will need to be prefixed by its parent hierarchy, if - // any. For example: top_property_name.sub_property_name. - // - // Sample Query: - // `(LOWER(driving_license)="class \"a\"" OR EMPTY(driving_license)) AND - // driving_years > 10` - // - // - // CMEK compliant deployment only supports: - // - // * Operators: `=`, `<`, `<=`, `>`, and `>=`. - // * Boolean expressions: AND and OR. - string condition = 2; -} - -// Filter for the specific types of documents returned. -message FileTypeFilter { - // Representation of the types of files. - enum FileType { - // Default document type. If set, disables the filter. - FILE_TYPE_UNSPECIFIED = 0; - - // Returns all document types, including folders. - ALL = 1; - - // Returns only folders. - FOLDER = 2; - - // Returns only non-folder documents. - DOCUMENT = 3; - } - - // The type of files to return. - FileType file_type = 1; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/histogram.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/histogram.proto deleted file mode 100644 index ce25e7a8c3f..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/histogram.proto +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.contentwarehouse.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "HistogramProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// The histogram request. -message HistogramQuery { - // An expression specifies a histogram request against matching documents for - // searches. - // - // See [SearchDocumentsRequest.histogram_queries][google.cloud.contentwarehouse.v1.SearchDocumentsRequest.histogram_queries] for details about syntax. - string histogram_query = 1; - - // Controls if the histogram query requires the return of a precise count. - // Enable this flag may adversely impact performance. - // - // Defaults to true. - bool require_precise_result_size = 2; - - // Optional. Filter the result of histogram query by the property names. It only works - // with histogram query count('FilterableProperties'). - // It is an optional. It will perform histogram on all the property names for - // all the document schemas. Setting this field will have a better - // performance. - HistogramQueryPropertyNameFilter filters = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -message HistogramQueryPropertyNameFilter { - // The result of the histogram query count('FilterableProperties') using - // HISTOGRAM_YAXIS_DOCUMENT will be: - // invoice_id: 2 - // address: 1 - // payment_method: 2 - // line_item_description: 1 - enum HistogramYAxis { - // Count the documents per property name. - HISTOGRAM_YAXIS_DOCUMENT = 0; - - // Count the properties per property name. - HISTOGRAM_YAXIS_PROPERTY = 1; - } - - // This filter specifies the exact document schema(s) - // [Document.document_schema_name][google.cloud.contentwarehouse.v1.Document.document_schema_name] to run histogram query against. - // It is optional. It will perform histogram for property names for all the - // document schemas if it is not set. - // - // At most 10 document schema names are allowed. - // Format: - // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. - repeated string document_schemas = 1 [(google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/DocumentSchema" - }]; - - // It is optional. It will perform histogram for all the property names if it - // is not set. - // The properties need to be defined with the is_filterable flag set to - // true and the name of the property should be in the format: - // "schemaId.propertyName". The property needs to be defined in the schema. - // Example: the schema id is abc. Then the name of property for property - // MORTGAGE_TYPE will be "abc.MORTGAGE_TYPE". - repeated string property_names = 2; - - // By default, the y_axis is HISTOGRAM_YAXIS_DOCUMENT if this field is not - // set. - HistogramYAxis y_axis = 3; -} - -// Histogram result that matches [HistogramQuery][google.cloud.contentwarehouse.v1.HistogramQuery] specified in searches. -message HistogramQueryResult { - // Requested histogram expression. - string histogram_query = 1; - - // A map from the values of the facet associated with distinct values to the - // number of matching entries with corresponding value. - // - // The key format is: - // - // * (for string histogram) string values stored in the field. - map histogram = 2; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/rule_engine.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/rule_engine.proto deleted file mode 100644 index 7badc7b788a..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/rule_engine.proto +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/policy.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "RuleEngineProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// Represents a set of rules from a single customer. -message RuleSet { - option (google.api.resource) = { - type: "contentwarehouse.googleapis.com/RuleSet" - pattern: "projects/{project}/locations/{location}/ruleSets/{rule_set}" - }; - - // The resource name of the rule set. Managed internally. - // Format: - // projects/{project_number}/locations/{location}/ruleSet/{rule_set_id}. - // - // The name is ignored when creating a rule set. - string name = 6; - - // Short description of the rule-set. - string description = 1; - - // Source of the rules i.e., customer name. - string source = 2; - - // List of rules given by the customer. - repeated Rule rules = 3; -} - -// Represents the rule for a content warehouse trigger. -message Rule { - enum TriggerType { - UNKNOWN = 0; - - // Trigger for create document action. - ON_CREATE = 1; - - // Trigger for update document action. - ON_UPDATE = 4; - } - - // Short description of the rule and its context. - string description = 1; - - // ID of the rule. It has to be unique across all the examples. - // This is managed internally. - string rule_id = 2; - - // Identifies the trigger type for running the policy. - TriggerType trigger_type = 3; - - // Represents the conditional expression to be evaluated. - // Expression should evaluate to a boolean result. - // When the condition is true actions are executed. - // Example: user_role = "hsbc_role_1" AND doc.salary > 20000 - string condition = 4; - - // List of actions that are executed when the rule is satisfied. - repeated Action actions = 5; -} - -// Represents the action triggered by Rule Engine when the rule is true. -message Action { - // ID of the action. Managed internally. - string action_id = 1; - - oneof action { - // Action triggering access control operations. - AccessControlAction access_control = 2; - - // Action triggering data validation operations. - DataValidationAction data_validation = 3; - - // Action triggering data update operations. - DataUpdateAction data_update = 4; - - // Action triggering create document link operation. - AddToFolderAction add_to_folder = 5; - - // Action publish to Pub/Sub operation. - PublishAction publish_to_pub_sub = 6; - - // Action removing a document from a folder. - RemoveFromFolderAction remove_from_folder_action = 9; - - // Action deleting the document. - DeleteDocumentAction delete_document_action = 10; - } -} - -// Represents the action responsible for access control list management -// operations. -message AccessControlAction { - // Type of ACL modification operation. - enum OperationType { - UNKNOWN = 0; - - // Adds newly given policy bindings in the existing bindings list. - ADD_POLICY_BINDING = 1; - - // Removes newly given policy bindings from the existing bindings list. - REMOVE_POLICY_BINDING = 2; - - // Replaces existing policy bindings with the given policy binding list - REPLACE_POLICY_BINDING = 3; - } - - // Identifies the type of operation. - OperationType operation_type = 1; - - // Represents the new policy from which bindings are added, removed or - // replaced based on the type of the operation. the policy is limited to a few - // 10s of KB. - google.iam.v1.Policy policy = 2; -} - -// Represents the action responsible for data validation operations. -message DataValidationAction { - // Map of (K, V) -> (field, string condition to be evaluated on the field) - // E.g., ("age", "age > 18 && age < 60") entry triggers validation of field - // age with the given condition. Map entries will be ANDed during validation. - map conditions = 1; -} - -// Represents the action responsible for properties update operations. -message DataUpdateAction { - // Map of (K, V) -> (valid name of the field, new value of the field) - // E.g., ("age", "60") entry triggers update of field age with a value of 60. - // If the field is not present then new entry is added. - // During update action execution, value strings will be casted to - // appropriate types. - map entries = 1; -} - -// Represents the action responsible for adding document under a folder. -message AddToFolderAction { - // Names of the folder under which new document is to be added. - // Format: - // projects/{project_number}/locations/{location}/documents/{document_id}. - repeated string folders = 1 [(google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Document" - }]; -} - -// Represents the action responsible for remove a document from a specific -// folder. -message RemoveFromFolderAction { - // Condition of the action to be executed. - string condition = 1; - - // Name of the folder under which new document is to be added. - // Format: - // projects/{project_number}/locations/{location}/documents/{document_id}. - string folder = 2 [(google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Document" - }]; -} - -// Represents the action responsible for publishing messages to a Pub/Sub topic. -message PublishAction { - // The topic id in the Pub/Sub service for which messages will be published - // to. - string topic_id = 1; - - // Messages to be published. - repeated string messages = 2; -} - -// Represents the action responsible for deleting the document. -message DeleteDocumentAction { - // Boolean field to select between hard vs soft delete options. - // Set 'true' for 'hard delete' and 'false' for 'soft delete'. - bool enable_hard_delete = 1; -} - -// Records the output of Rule Engine including rule evaluation and actions -// result. -message RuleEngineOutput { - // Name of the document against which the rules and actions were evaluated. - string document_name = 3; - - // Output from Rule Evaluator containing matched, unmatched and invalid rules. - RuleEvaluatorOutput rule_evaluator_output = 1; - - // Output from Action Executor containing rule and corresponding actions - // execution result. - ActionExecutorOutput action_executor_output = 2; -} - -// Represents the output of the Rule Evaluator. -message RuleEvaluatorOutput { - // List of rules fetched from database for the given request trigger type. - repeated Rule triggered_rules = 1; - - // A subset of triggered rules that are evaluated true for a given request. - repeated Rule matched_rules = 2; - - // A subset of triggered rules that failed the validation check(s) after - // parsing. - repeated InvalidRule invalid_rules = 3; -} - -// A triggered rule that failed the validation check(s) after parsing. -message InvalidRule { - // Triggered rule. - Rule rule = 1; - - // Validation error on a parsed expression. - string error = 2; -} - -// Represents the output of the Action Executor. -message ActionExecutorOutput { - // List of rule and corresponding actions result. - repeated RuleActionsPair rule_actions_pairs = 1; -} - -// Represents a rule and outputs of associated actions. -message RuleActionsPair { - // Represents the rule. - Rule rule = 1; - - // Outputs of executing the actions associated with the above rule. - repeated ActionOutput action_outputs = 2; -} - -// Represents the result of executing an action. -message ActionOutput { - // Represents execution state of the action. - enum State { - UNKNOWN = 0; - - // State indicating action executed successfully. - ACTION_SUCCEEDED = 1; - - // State indicating action failed. - ACTION_FAILED = 2; - - // State indicating action timed out. - ACTION_TIMED_OUT = 3; - - // State indicating action is pending. - ACTION_PENDING = 4; - } - - // ID of the action. - string action_id = 1; - - // State of an action. - State action_state = 2; - - // Action execution output message. - string output_message = 3; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service.proto deleted file mode 100644 index 091367eabee..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service.proto +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/cloud/contentwarehouse/v1/rule_engine.proto"; -import "google/cloud/contentwarehouse/v1/ruleset_service_request.proto"; -import "google/protobuf/empty.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "RuleSetServiceProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// Service to manage customer specific RuleSets. -service RuleSetService { - option (google.api.default_host) = "contentwarehouse.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a ruleset. - rpc CreateRuleSet(CreateRuleSetRequest) returns (RuleSet) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/ruleSets" - body: "rule_set" - }; - option (google.api.method_signature) = "parent,rule_set"; - } - - // Gets a ruleset. Returns NOT_FOUND if the ruleset does not exist. - rpc GetRuleSet(GetRuleSetRequest) returns (RuleSet) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/ruleSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a ruleset. Returns INVALID_ARGUMENT if the name of the ruleset - // is non-empty and does not equal the existing name. - rpc UpdateRuleSet(UpdateRuleSetRequest) returns (RuleSet) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/ruleSets/*}" - body: "*" - }; - option (google.api.method_signature) = "name,rule_set"; - } - - // Deletes a ruleset. Returns NOT_FOUND if the document does not exist. - rpc DeleteRuleSet(DeleteRuleSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/ruleSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists rulesets. - rpc ListRuleSets(ListRuleSetsRequest) returns (ListRuleSetsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/ruleSets" - }; - option (google.api.method_signature) = "parent"; - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto deleted file mode 100644 index 61d12510680..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/contentwarehouse/v1/rule_engine.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "RuleSetServiceRequestProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// Request message for RuleSetService.CreateRuleSet. -message CreateRuleSetRequest { - // Required. The parent name. - // Format: projects/{project_number}/locations/{location}. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Location" - } - ]; - - // Required. The rule set to create. - RuleSet rule_set = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for RuleSetService.GetRuleSet. -message GetRuleSetRequest { - // Required. The name of the rule set to retrieve. - // Format: - // projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/RuleSet" - } - ]; -} - -// Request message for RuleSetService.UpdateRuleSet. -message UpdateRuleSetRequest { - // Required. The name of the rule set to update. - // Format: - // projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/RuleSet" - } - ]; - - // Required. The rule set to update. - RuleSet rule_set = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for RuleSetService.DeleteRuleSet. -message DeleteRuleSetRequest { - // Required. The name of the rule set to delete. - // Format: - // projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/RuleSet" - } - ]; -} - -// Request message for RuleSetService.ListRuleSets. -message ListRuleSetsRequest { - // Required. The parent, which owns this collection of document. - // Format: projects/{project_number}/locations/{location}. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Location" - } - ]; - - // The maximum number of rule sets to return. The service may return - // fewer than this value. - // If unspecified, at most 50 rule sets will be returned. - // The maximum value is 1000; values above 1000 will be coerced to 1000. - int32 page_size = 2; - - // A page token, received from a previous `ListRuleSets` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListRuleSets` - // must match the call that provided the page token. - string page_token = 3; -} - -// Response message for RuleSetService.ListRuleSets. -message ListRuleSetsResponse { - // The rule sets from the specified parent. - repeated RuleSet rule_sets = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset.proto deleted file mode 100644 index d4f23e0571e..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset.proto +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/resource.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "SynonymSetProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// Represents a list of synonyms for a given context. -// For example a context "sales" could contain: -// Synonym 1: sale, invoice, bill, order -// Synonym 2: money, credit, finance, payment -// Synonym 3: shipping, freight, transport -// Each SynonymSets should be disjoint -message SynonymSet { - option (google.api.resource) = { - type: "contentwarehouse.googleapis.com/SynonymSet" - pattern: "projects/{project}/locations/{location}/synonymSets/{context}" - }; - - // Represents a list of words given by the customer - // All these words are synonyms of each other. - message Synonym { - // For example: sale, invoice, bill, order - repeated string words = 1; - } - - // The resource name of the SynonymSet - // This is mandatory for google.api.resource. - // Format: - // projects/{project_number}/locations/{location}/synonymSets/{context}. - string name = 1; - - // This is a freeform field. Example contexts can be "sales," "engineering," - // "real estate," "accounting," etc. - // The context can be supplied during search requests. - string context = 2; - - // List of Synonyms for the context. - repeated Synonym synonyms = 3; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service.proto deleted file mode 100644 index 39acfd112ae..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service.proto +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/cloud/contentwarehouse/v1/synonymset.proto"; -import "google/cloud/contentwarehouse/v1/synonymset_service_request.proto"; -import "google/protobuf/empty.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "SynonymSetServiceProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// A Service that manage/custom customer specified SynonymSets. -service SynonymSetService { - option (google.api.default_host) = "contentwarehouse.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a SynonymSet for a single context. - // Throws an ALREADY_EXISTS exception if a synonymset already exists - // for the context. - rpc CreateSynonymSet(CreateSynonymSetRequest) returns (SynonymSet) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/synonymSets" - body: "synonym_set" - }; - option (google.api.method_signature) = "parent,synonym_set"; - } - - // Gets a SynonymSet for a particular context. - // Throws a NOT_FOUND exception if the Synonymset - // does not exist - rpc GetSynonymSet(GetSynonymSetRequest) returns (SynonymSet) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/synonymSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Remove the existing SynonymSet for the context and replaces it - // with a new one. - // Throws a NOT_FOUND exception if the SynonymSet is not found. - rpc UpdateSynonymSet(UpdateSynonymSetRequest) returns (SynonymSet) { - option (google.api.http) = { - patch: "/v1/{name=projects/*/locations/*/synonymSets/*}" - body: "synonym_set" - }; - option (google.api.method_signature) = "name,synonym_set"; - } - - // Deletes a SynonymSet for a given context. - // Throws a NOT_FOUND exception if the SynonymSet is not found. - rpc DeleteSynonymSet(DeleteSynonymSetRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/synonymSets/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Returns all SynonymSets (for all contexts) for the specified location. - rpc ListSynonymSets(ListSynonymSetsRequest) returns (ListSynonymSetsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/synonymSets" - }; - option (google.api.method_signature) = "parent"; - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto deleted file mode 100644 index 8d1955456d3..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.contentwarehouse.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/contentwarehouse/v1/synonymset.proto"; - -option go_package = "google.golang.org/genproto/googleapis/cloud/contentwarehouse/v1;contentwarehouse"; -option java_multiple_files = true; -option java_outer_classname = "SynonymSetServiceRequestProto"; -option java_package = "com.google.cloud.contentwarehouse.v1"; - -// Request message for SynonymSetService.CreateSynonymSet. -message CreateSynonymSetRequest { - // Required. The parent name. - // Format: projects/{project_number}/locations/{location}. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Location" - } - ]; - - // Required. The synonymSet to be created for a context - SynonymSet synonym_set = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for SynonymSetService.GetSynonymSet. -// Will return synonymSet for a certain context. -message GetSynonymSetRequest { - // Required. The name of the synonymSet to retrieve - // Format: - // projects/{project_number}/locations/{location}/synonymSets/{context}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/SynonymSet" - } - ]; -} - -// Request message for SynonymSetService.ListSynonymSets. -// Will return all synonymSets belonging to the customer project. -message ListSynonymSetsRequest { - // Required. The parent name. - // Format: projects/{project_number}/locations/{location}. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/Location" - } - ]; - - // The maximum number of synonymSets to return. The service may return - // fewer than this value. - // If unspecified, at most 50 rule sets will be returned. - // The maximum value is 1000; values above 1000 will be coerced to 1000. - int32 page_size = 2; - - // A page token, received from a previous `ListSynonymSets` call. - // Provide this to retrieve the subsequent page. - // - // When paginating, all other parameters provided to `ListSynonymSets` - // must match the call that provided the page token. - string page_token = 3; -} - -// Response message for SynonymSetService.ListSynonymSets. -message ListSynonymSetsResponse { - // The synonymSets from the specified parent. - repeated SynonymSet synonym_sets = 1; - - // A page token, received from a previous `ListSynonymSets` call. - // Provide this to retrieve the subsequent page. - string next_page_token = 2; -} - -// Request message for SynonymSetService.UpdateSynonymSet. -// Removes the SynonymSet for the specified context and replaces -// it with the SynonymSet in this request. -message UpdateSynonymSetRequest { - // Required. The name of the synonymSet to update - // Format: - // projects/{project_number}/locations/{location}/synonymSets/{context}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/SynonymSet" - } - ]; - - // Required. The synonymSet to be updated for the customer - SynonymSet synonym_set = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for SynonymSetService.DeleteSynonymSet. -message DeleteSynonymSetRequest { - // Required. The name of the synonymSet to delete - // Format: - // projects/{project_number}/locations/{location}/synonymSets/{context}. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "contentwarehouse.googleapis.com/SynonymSet" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/barcode.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/barcode.proto deleted file mode 100644 index bb841771ade..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/barcode.proto +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "BarcodeProto"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// Encodes the detailed information of a barcode. -message Barcode { - // Format of a barcode. - // The supported formats are: - // - // - `CODE_128`: Code 128 type. - // - `CODE_39`: Code 39 type. - // - `CODE_93`: Code 93 type. - // - `CODABAR`: Codabar type. - // - `DATA_MATRIX`: 2D Data Matrix type. - // - `ITF`: ITF type. - // - `EAN_13`: EAN-13 type. - // - `EAN_8`: EAN-8 type. - // - `QR_CODE`: 2D QR code type. - // - `UPC_A`: UPC-A type. - // - `UPC_E`: UPC-E type. - // - `PDF417`: PDF417 type. - // - `AZTEC`: 2D Aztec code type. - // - `DATABAR`: GS1 DataBar code type. - string format = 1; - - // Value format describes the format of the value that a barcode - // encodes. - // The supported formats are: - // - // - `CONTACT_INFO`: Contact information. - // - `EMAIL`: Email address. - // - `ISBN`: ISBN identifier. - // - `PHONE`: Phone number. - // - `PRODUCT`: Product. - // - `SMS`: SMS message. - // - `TEXT`: Text string. - // - `URL`: URL address. - // - `WIFI`: Wifi information. - // - `GEO`: Geo-localization. - // - `CALENDAR_EVENT`: Calendar event. - // - `DRIVER_LICENSE`: Driver's license. - string value_format = 2; - - // Raw value encoded in the barcode. - // For example: `'MEBKM:TITLE:Google;URL:https://www.google.com;;'`. - string raw_value = 3; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document.proto deleted file mode 100644 index c4fbb21ceca..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document.proto +++ /dev/null @@ -1,820 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/api/field_behavior.proto"; -import "google/cloud/documentai/v1/barcode.proto"; -import "google/cloud/documentai/v1/geometry.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/date.proto"; -import "google/type/datetime.proto"; -import "google/type/money.proto"; -import "google/type/postal_address.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentProto"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// Document represents the canonical document resource in Document AI. It is an -// interchange format that provides insights into documents and allows for -// collaboration between users and Document AI to iterate and optimize for -// quality. -message Document { - // For a large document, sharding may be performed to produce several - // document shards. Each document shard contains this field to detail which - // shard it is. - message ShardInfo { - // The 0-based index of this shard. - int64 shard_index = 1; - - // Total number of shards. - int64 shard_count = 2; - - // The index of the first character in [Document.text][google.cloud.documentai.v1.Document.text] in the overall - // document global text. - int64 text_offset = 3; - } - - // Annotation for common text style attributes. This adheres to CSS - // conventions as much as possible. - message Style { - // Font size with unit. - message FontSize { - // Font size for the text. - float size = 1; - - // Unit for the font size. Follows CSS naming (in, px, pt, etc.). - string unit = 2; - } - - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. - TextAnchor text_anchor = 1; - - // Text color. - google.type.Color color = 2; - - // Text background color. - google.type.Color background_color = 3; - - // Font weight. Possible values are normal, bold, bolder, and lighter. - // https://www.w3schools.com/cssref/pr_font_weight.asp - string font_weight = 4; - - // Text style. Possible values are normal, italic, and oblique. - // https://www.w3schools.com/cssref/pr_font_font-style.asp - string text_style = 5; - - // Text decoration. Follows CSS standard. - // - // https://www.w3schools.com/cssref/pr_text_text-decoration.asp - string text_decoration = 6; - - // Font size. - FontSize font_size = 7; - - // Font family such as `Arial`, `Times New Roman`. - // https://www.w3schools.com/cssref/pr_font_font-family.asp - string font_family = 8; - } - - // A page in a [Document][google.cloud.documentai.v1.Document]. - message Page { - // Dimension for the page. - message Dimension { - // Page width. - float width = 1; - - // Page height. - float height = 2; - - // Dimension unit. - string unit = 3; - } - - // Rendered image contents for this page. - message Image { - // Raw byte content of the image. - bytes content = 1; - - // Encoding mime type for the image. - string mime_type = 2; - - // Width of the image in pixels. - int32 width = 3; - - // Height of the image in pixels. - int32 height = 4; - } - - // Representation for transformation matrix, intended to be compatible and - // used with OpenCV format for image manipulation. - message Matrix { - // Number of rows in the matrix. - int32 rows = 1; - - // Number of columns in the matrix. - int32 cols = 2; - - // This encodes information about what data type the matrix uses. - // For example, 0 (CV_8U) is an unsigned 8-bit image. For the full list - // of OpenCV primitive data types, please refer to - // https://docs.opencv.org/4.3.0/d1/d1b/group__core__hal__interface.html - int32 type = 3; - - // The matrix data. - bytes data = 4; - } - - // Visual element describing a layout unit on a page. - message Layout { - // Detected human reading orientation. - enum Orientation { - // Unspecified orientation. - ORIENTATION_UNSPECIFIED = 0; - - // Orientation is aligned with page up. - PAGE_UP = 1; - - // Orientation is aligned with page right. - // Turn the head 90 degrees clockwise from upright to read. - PAGE_RIGHT = 2; - - // Orientation is aligned with page down. - // Turn the head 180 degrees from upright to read. - PAGE_DOWN = 3; - - // Orientation is aligned with page left. - // Turn the head 90 degrees counterclockwise from upright to read. - PAGE_LEFT = 4; - } - - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. - TextAnchor text_anchor = 1; - - // Confidence of the current [Layout][google.cloud.documentai.v1.Document.Page.Layout] within context of the object this - // layout is for. e.g. confidence can be for a single token, a table, - // a visual element, etc. depending on context. Range `[0, 1]`. - float confidence = 2; - - // The bounding polygon for the [Layout][google.cloud.documentai.v1.Document.Page.Layout]. - BoundingPoly bounding_poly = 3; - - // Detected orientation for the [Layout][google.cloud.documentai.v1.Document.Page.Layout]. - Orientation orientation = 4; - } - - // A block has a set of lines (collected into paragraphs) that have a - // common line-spacing and orientation. - message Block { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Block][google.cloud.documentai.v1.Document.Page.Block]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - - // The history of this annotation. - Provenance provenance = 3 [deprecated = true]; - } - - // A collection of lines that a human would perceive as a paragraph. - message Paragraph { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1.Document.Page.Paragraph]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - - // The history of this annotation. - Provenance provenance = 3 [deprecated = true]; - } - - // A collection of tokens that a human would perceive as a line. - // Does not cross column boundaries, can be horizontal, vertical, etc. - message Line { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Line][google.cloud.documentai.v1.Document.Page.Line]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - - // The history of this annotation. - Provenance provenance = 3 [deprecated = true]; - } - - // A detected token. - message Token { - // Detected break at the end of a [Token][google.cloud.documentai.v1.Document.Page.Token]. - message DetectedBreak { - // Enum to denote the type of break found. - enum Type { - // Unspecified break type. - TYPE_UNSPECIFIED = 0; - - // A single whitespace. - SPACE = 1; - - // A wider whitespace. - WIDE_SPACE = 2; - - // A hyphen that indicates that a token has been split across lines. - HYPHEN = 3; - } - - // Detected break type. - Type type = 1; - } - - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Token][google.cloud.documentai.v1.Document.Page.Token]. - Layout layout = 1; - - // Detected break at the end of a [Token][google.cloud.documentai.v1.Document.Page.Token]. - DetectedBreak detected_break = 2; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 3; - - // The history of this annotation. - Provenance provenance = 4 [deprecated = true]; - } - - // A detected symbol. - message Symbol { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Symbol][google.cloud.documentai.v1.Document.Page.Symbol]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - } - - // Detected non-text visual elements e.g. checkbox, signature etc. on the - // page. - message VisualElement { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1.Document.Page.VisualElement]. - Layout layout = 1; - - // Type of the [VisualElement][google.cloud.documentai.v1.Document.Page.VisualElement]. - string type = 2; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 3; - } - - // A table representation similar to HTML table structure. - message Table { - // A row of table cells. - message TableRow { - // Cells that make up this row. - repeated TableCell cells = 1; - } - - // A cell representation inside the table. - message TableCell { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1.Document.Page.Table.TableCell]. - Layout layout = 1; - - // How many rows this cell spans. - int32 row_span = 2; - - // How many columns this cell spans. - int32 col_span = 3; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 4; - } - - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Table][google.cloud.documentai.v1.Document.Page.Table]. - Layout layout = 1; - - // Header rows of the table. - repeated TableRow header_rows = 2; - - // Body rows of the table. - repeated TableRow body_rows = 3; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 4; - - // The history of this table. - Provenance provenance = 5; - } - - // A form field detected on the page. - message FormField { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1.Document.Page.FormField] name. e.g. `Address`, `Email`, - // `Grand total`, `Phone number`, etc. - Layout field_name = 1; - - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1.Document.Page.FormField] value. - Layout field_value = 2; - - // A list of detected languages for name together with confidence. - repeated DetectedLanguage name_detected_languages = 3; - - // A list of detected languages for value together with confidence. - repeated DetectedLanguage value_detected_languages = 4; - - // If the value is non-textual, this field represents the type. Current - // valid values are: - // - blank (this indicates the field_value is normal text) - // - "unfilled_checkbox" - // - "filled_checkbox" - string value_type = 5; - - // Created for Labeling UI to export key text. - // If corrections were made to the text identified by the - // `field_name.text_anchor`, this field will contain the correction. - string corrected_key_text = 6; - - // Created for Labeling UI to export value text. - // If corrections were made to the text identified by the - // `field_value.text_anchor`, this field will contain the correction. - string corrected_value_text = 7; - - // The history of this annotation. - Provenance provenance = 8; - } - - // A detected barcode. - message DetectedBarcode { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [DetectedBarcode][google.cloud.documentai.v1.Document.Page.DetectedBarcode]. - Layout layout = 1; - - // Detailed barcode information of the [DetectedBarcode][google.cloud.documentai.v1.Document.Page.DetectedBarcode]. - Barcode barcode = 2; - } - - // Detected language for a structural component. - message DetectedLanguage { - // The BCP-47 language code, such as `en-US` or `sr-Latn`. For more - // information, see - // https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 1; - - // Confidence of detected language. Range `[0, 1]`. - float confidence = 2; - } - - // Image Quality Scores for the page image - message ImageQualityScores { - // Image Quality Defects - message DetectedDefect { - // Name of the defect type. Supported values are: - // - // - `quality/defect_blurry` - // - `quality/defect_noisy` - // - `quality/defect_dark` - // - `quality/defect_faint` - // - `quality/defect_text_too_small` - // - `quality/defect_document_cutoff` - // - `quality/defect_text_cutoff` - // - `quality/defect_glare` - string type = 1; - - // Confidence of detected defect. Range `[0, 1]` where 1 indicates - // strong confidence of that the defect exists. - float confidence = 2; - } - - // The overall quality score. Range `[0, 1]` where 1 is perfect quality. - float quality_score = 1; - - // A list of detected defects. - repeated DetectedDefect detected_defects = 2; - } - - // 1-based index for current [Page][google.cloud.documentai.v1.Document.Page] in a parent [Document][google.cloud.documentai.v1.Document]. - // Useful when a page is taken out of a [Document][google.cloud.documentai.v1.Document] for individual - // processing. - int32 page_number = 1; - - // Rendered image for this page. This image is preprocessed to remove any - // skew, rotation, and distortions such that the annotation bounding boxes - // can be upright and axis-aligned. - Image image = 13; - - // Transformation matrices that were applied to the original document image - // to produce [Page.image][google.cloud.documentai.v1.Document.Page.image]. - repeated Matrix transforms = 14; - - // Physical dimension of the page. - Dimension dimension = 2; - - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the page. - Layout layout = 3; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 4; - - // A list of visually detected text blocks on the page. - // A block has a set of lines (collected into paragraphs) that have a common - // line-spacing and orientation. - repeated Block blocks = 5; - - // A list of visually detected text paragraphs on the page. - // A collection of lines that a human would perceive as a paragraph. - repeated Paragraph paragraphs = 6; - - // A list of visually detected text lines on the page. - // A collection of tokens that a human would perceive as a line. - repeated Line lines = 7; - - // A list of visually detected tokens on the page. - repeated Token tokens = 8; - - // A list of detected non-text visual elements e.g. checkbox, - // signature etc. on the page. - repeated VisualElement visual_elements = 9; - - // A list of visually detected tables on the page. - repeated Table tables = 10; - - // A list of visually detected form fields on the page. - repeated FormField form_fields = 11; - - // A list of visually detected symbols on the page. - repeated Symbol symbols = 12; - - // A list of detected barcodes. - repeated DetectedBarcode detected_barcodes = 15; - - // Image Quality Scores. - ImageQualityScores image_quality_scores = 17; - - // The history of this page. - Provenance provenance = 16 [deprecated = true]; - } - - // An entity that could be a phrase in the text or a property that belongs to - // the document. It is a known entity type, such as a person, an organization, - // or location. - message Entity { - // Parsed and normalized entity value. - message NormalizedValue { - // An optional structured entity value. - // Must match entity type defined in schema if - // known. If this field is present, the `text` field could also be - // populated. - oneof structured_value { - // Money value. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/money.proto - google.type.Money money_value = 2; - - // Date value. Includes year, month, day. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/date.proto - google.type.Date date_value = 3; - - // DateTime value. Includes date, time, and timezone. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto - google.type.DateTime datetime_value = 4; - - // Postal address. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto - google.type.PostalAddress address_value = 5; - - // Boolean value. Can be used for entities with binary values, or for - // checkboxes. - bool boolean_value = 6; - - // Integer value. - int32 integer_value = 7; - - // Float value. - float float_value = 8; - } - - // Optional. An optional field to store a normalized string. - // For some entity types, one of respective `structured_value` fields may - // also be populated. Also not all the types of `structured_value` will be - // normalized. For example, some processors may not generate float - // or int normalized text by default. - // - // Below are sample formats mapped to structured values. - // - // - Money/Currency type (`money_value`) is in the ISO 4217 text format. - // - Date type (`date_value`) is in the ISO 8601 text format. - // - Datetime type (`datetime_value`) is in the ISO 8601 text format. - string text = 1 [(google.api.field_behavior) = OPTIONAL]; - } - - // Optional. Provenance of the entity. - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. - TextAnchor text_anchor = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Required. Entity type from a schema e.g. `Address`. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`. - string mention_text = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Deprecated. Use `id` field instead. - string mention_id = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Confidence of detected Schema entity. Range `[0, 1]`. - float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Represents the provenance of this entity wrt. the location on the - // page where it was found. - PageAnchor page_anchor = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Canonical id. This will be a unique value in the entity list - // for this document. - string id = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Normalized entity value. Absent if the extracted value could not be - // converted or the type (e.g. address) is not supported for certain - // parsers. This field is also only populated for certain supported document - // types. - NormalizedValue normalized_value = 9 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Entities can be nested to form a hierarchical data structure representing - // the content in the document. - repeated Entity properties = 10 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The history of this annotation. - Provenance provenance = 11 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Whether the entity will be redacted for de-identification purposes. - bool redacted = 12 [(google.api.field_behavior) = OPTIONAL]; - } - - // Relationship between [Entities][google.cloud.documentai.v1.Document.Entity]. - message EntityRelation { - // Subject entity id. - string subject_id = 1; - - // Object entity id. - string object_id = 2; - - // Relationship description. - string relation = 3; - } - - // Text reference indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. - message TextAnchor { - // A text segment in the [Document.text][google.cloud.documentai.v1.Document.text]. The indices may be out of bounds - // which indicate that the text extends into another document shard for - // large sharded documents. See [ShardInfo.text_offset][google.cloud.documentai.v1.Document.ShardInfo.text_offset] - message TextSegment { - // [TextSegment][google.cloud.documentai.v1.Document.TextAnchor.TextSegment] start UTF-8 char index in the [Document.text][google.cloud.documentai.v1.Document.text]. - int64 start_index = 1; - - // [TextSegment][google.cloud.documentai.v1.Document.TextAnchor.TextSegment] half open end UTF-8 char index in the - // [Document.text][google.cloud.documentai.v1.Document.text]. - int64 end_index = 2; - } - - // The text segments from the [Document.text][google.cloud.documentai.v1.Document.text]. - repeated TextSegment text_segments = 1; - - // Contains the content of the text span so that users do - // not have to look it up in the text_segments. It is always - // populated for formFields. - string content = 2; - } - - // Referencing the visual context of the entity in the [Document.pages][google.cloud.documentai.v1.Document.pages]. - // Page anchors can be cross-page, consist of multiple bounding polygons and - // optionally reference specific layout element types. - message PageAnchor { - // Represents a weak reference to a page element within a document. - message PageRef { - // The type of layout that is being referenced. - enum LayoutType { - // Layout Unspecified. - LAYOUT_TYPE_UNSPECIFIED = 0; - - // References a [Page.blocks][google.cloud.documentai.v1.Document.Page.blocks] element. - BLOCK = 1; - - // References a [Page.paragraphs][google.cloud.documentai.v1.Document.Page.paragraphs] element. - PARAGRAPH = 2; - - // References a [Page.lines][google.cloud.documentai.v1.Document.Page.lines] element. - LINE = 3; - - // References a [Page.tokens][google.cloud.documentai.v1.Document.Page.tokens] element. - TOKEN = 4; - - // References a [Page.visual_elements][google.cloud.documentai.v1.Document.Page.visual_elements] element. - VISUAL_ELEMENT = 5; - - // Refrrences a [Page.tables][google.cloud.documentai.v1.Document.Page.tables] element. - TABLE = 6; - - // References a [Page.form_fields][google.cloud.documentai.v1.Document.Page.form_fields] element. - FORM_FIELD = 7; - } - - // Required. Index into the [Document.pages][google.cloud.documentai.v1.Document.pages] element, for example using - // [Document.pages][page_refs.page] to locate the related page element. - // This field is skipped when its value is the default 0. See - // https://developers.google.com/protocol-buffers/docs/proto3#json. - int64 page = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The type of the layout element that is being referenced if any. - LayoutType layout_type = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Deprecated. Use [PageRef.bounding_poly][google.cloud.documentai.v1.Document.PageAnchor.PageRef.bounding_poly] instead. - string layout_id = 3 [ - deprecated = true, - (google.api.field_behavior) = OPTIONAL - ]; - - // Optional. Identifies the bounding polygon of a layout element on the page. - BoundingPoly bounding_poly = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Confidence of detected page element, if applicable. Range `[0, 1]`. - float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; - } - - // One or more references to visual page elements - repeated PageRef page_refs = 1; - } - - // Structure to identify provenance relationships between annotations in - // different revisions. - message Provenance { - // The parent element the current element is based on. Used for - // referencing/aligning, removal and replacement operations. - message Parent { - // The index of the index into current revision's parent_ids list. - int32 revision = 1; - - // The index of the parent item in the corresponding item list (eg. list - // of entities, properties within entities, etc.) in the parent revision. - int32 index = 3; - - // The id of the parent provenance. - int32 id = 2 [deprecated = true]; - } - - // If a processor or agent does an explicit operation on existing elements. - enum OperationType { - // Operation type unspecified. If no operation is specified a provenance - // entry is simply used to match against a `parent`. - OPERATION_TYPE_UNSPECIFIED = 0; - - // Add an element. - ADD = 1; - - // Remove an element identified by `parent`. - REMOVE = 2; - - // Replace an element identified by `parent`. - REPLACE = 3; - - // Request human review for the element identified by `parent`. - EVAL_REQUESTED = 4; - - // Element is reviewed and approved at human review, confidence will be - // set to 1.0. - EVAL_APPROVED = 5; - - // Element is skipped in the validation process. - EVAL_SKIPPED = 6; - } - - // The index of the revision that produced this element. - int32 revision = 1; - - // The Id of this operation. Needs to be unique within the scope of the - // revision. - int32 id = 2 [deprecated = true]; - - // References to the original elements that are replaced. - repeated Parent parents = 3; - - // The type of provenance operation. - OperationType type = 4; - } - - // Contains past or forward revisions of this document. - message Revision { - // Human Review information of the document. - message HumanReview { - // Human review state. e.g. `requested`, `succeeded`, `rejected`. - string state = 1; - - // A message providing more details about the current state of processing. - // For example, the rejection reason when the state is `rejected`. - string state_message = 2; - } - - // Who/what made the change - oneof source { - // If the change was made by a person specify the name or id of that - // person. - string agent = 4; - - // If the annotation was made by processor identify the processor by its - // resource name. - string processor = 5; - } - - // Id of the revision. Unique within the context of the document. - string id = 1; - - // The revisions that this revision is based on. This can include one or - // more parent (when documents are merged.) This field represents the - // index into the `revisions` field. - repeated int32 parent = 2 [deprecated = true]; - - // The revisions that this revision is based on. Must include all the ids - // that have anything to do with this revision - eg. there are - // `provenance.parent.revision` fields that index into this field. - repeated string parent_ids = 7; - - // The time that the revision was created. - google.protobuf.Timestamp create_time = 3; - - // Human Review information of this revision. - HumanReview human_review = 6; - } - - // This message is used for text changes aka. OCR corrections. - message TextChange { - // Provenance of the correction. - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. There can only be a - // single `TextAnchor.text_segments` element. If the start and - // end index of the text segment are the same, the text change is inserted - // before that index. - TextAnchor text_anchor = 1; - - // The text that replaces the text identified in the `text_anchor`. - string changed_text = 2; - - // The history of this annotation. - repeated Provenance provenance = 3 [deprecated = true]; - } - - // Original source document from the user. - oneof source { - // Optional. Currently supports Google Cloud Storage URI of the form - // `gs://bucket_name/object_name`. Object versioning is not supported. - // See [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris) for more - // info. - string uri = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Inline document content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - bytes content = 2 [(google.api.field_behavior) = OPTIONAL]; - } - - // An IANA published MIME type (also referred to as media type). For more - // information, see - // https://www.iana.org/assignments/media-types/media-types.xhtml. - string mime_type = 3; - - // Optional. UTF-8 encoded text in reading order from the document. - string text = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Placeholder. Styles for the [Document.text][google.cloud.documentai.v1.Document.text]. - repeated Style text_styles = 5; - - // Visual page layout for the [Document][google.cloud.documentai.v1.Document]. - repeated Page pages = 6; - - // A list of entities detected on [Document.text][google.cloud.documentai.v1.Document.text]. For document shards, - // entities in this list may cross shard boundaries. - repeated Entity entities = 7; - - // Placeholder. Relationship among [Document.entities][google.cloud.documentai.v1.Document.entities]. - repeated EntityRelation entity_relations = 8; - - // Placeholder. A list of text corrections made to [Document.text][google.cloud.documentai.v1.Document.text]. This - // is usually used for annotating corrections to OCR mistakes. Text changes - // for a given revision may not overlap with each other. - repeated TextChange text_changes = 14; - - // Information about the sharding if this document is sharded part of a larger - // document. If the document is not sharded, this message is not specified. - ShardInfo shard_info = 9; - - // Any error that occurred while processing this document. - google.rpc.Status error = 10; - - // Placeholder. Revision history of this document. - repeated Revision revisions = 13; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_io.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_io.proto deleted file mode 100644 index d56086336d2..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_io.proto +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentIoProto"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// Payload message of raw document content (bytes). -message RawDocument { - // Inline document content. - bytes content = 1; - - // An IANA MIME type (RFC6838) indicating the nature and format of the - // [content][google.cloud.documentai.v1.RawDocument.content]. - string mime_type = 2; -} - -// Specifies a document stored on Cloud Storage. -message GcsDocument { - // The Cloud Storage object uri. - string gcs_uri = 1; - - // An IANA MIME type (RFC6838) of the content. - string mime_type = 2; -} - -// Specifies a set of documents on Cloud Storage. -message GcsDocuments { - // The list of documents. - repeated GcsDocument documents = 1; -} - -// Specifies all documents on Cloud Storage with a common prefix. -message GcsPrefix { - // The URI prefix. - string gcs_uri_prefix = 1; -} - -// The common config to specify a set of documents used as input. -message BatchDocumentsInputConfig { - // The source. - oneof source { - // The set of documents that match the specified Cloud Storage `gcs_prefix`. - GcsPrefix gcs_prefix = 1; - - // The set of documents individually specified on Cloud Storage. - GcsDocuments gcs_documents = 2; - } -} - -// Config that controls the output of documents. All documents will be written -// as a JSON file. -message DocumentOutputConfig { - // The configuration used when outputting documents. - message GcsOutputConfig { - // The sharding config for the output document. - message ShardingConfig { - // The number of pages per shard. - int32 pages_per_shard = 1; - - // The number of overlapping pages between consecutive shards. - int32 pages_overlap = 2; - } - - // The Cloud Storage uri (a directory) of the output. - string gcs_uri = 1; - - // Specifies which fields to include in the output documents. - // Only supports top level document and pages field so it must be in the - // form of `{document_field_name}` or `pages.{page_field_name}`. - google.protobuf.FieldMask field_mask = 2; - - // Specifies the sharding config for the output document. - ShardingConfig sharding_config = 3; - } - - // The destination of the results. - oneof destination { - // Output config to write the results to Cloud Storage. - GcsOutputConfig gcs_output_config = 1; - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_processor_service.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_processor_service.proto deleted file mode 100644 index e748ae1f748..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_processor_service.proto +++ /dev/null @@ -1,801 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/documentai/v1/document.proto"; -import "google/cloud/documentai/v1/document_io.proto"; -import "google/cloud/documentai/v1/document_schema.proto"; -import "google/cloud/documentai/v1/operation_metadata.proto"; -import "google/cloud/documentai/v1/processor.proto"; -import "google/cloud/documentai/v1/processor_type.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProcessorService"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; -option (google.api.resource_definition) = { - type: "documentai.googleapis.com/HumanReviewConfig" - pattern: "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" -}; -option (google.api.resource_definition) = { - type: "documentai.googleapis.com/Location" - pattern: "projects/{project}/locations/{location}" -}; - -// Service to call Cloud DocumentAI to process documents according to the -// processor's definition. Processors are built using state-of-the-art Google -// AI such as natural language, computer vision, and translation to extract -// structured information from unstructured or semi-structured documents. -service DocumentProcessorService { - option (google.api.default_host) = "documentai.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Processes a single document. - rpc ProcessDocument(ProcessRequest) returns (ProcessResponse) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*}:process" - body: "*" - additional_bindings { - post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:process" - body: "*" - } - }; - option (google.api.method_signature) = "name"; - } - - // LRO endpoint to batch process many documents. The output is written - // to Cloud Storage as JSON in the [Document] format. - rpc BatchProcessDocuments(BatchProcessRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*}:batchProcess" - body: "*" - additional_bindings { - post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:batchProcess" - body: "*" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "BatchProcessResponse" - metadata_type: "BatchProcessMetadata" - }; - } - - // Fetches processor types. Note that we do not use ListProcessorTypes here - // because it is not paginated. - rpc FetchProcessorTypes(FetchProcessorTypesRequest) returns (FetchProcessorTypesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}:fetchProcessorTypes" - }; - option (google.api.method_signature) = "parent"; - } - - // Lists the processor types that exist. - rpc ListProcessorTypes(ListProcessorTypesRequest) returns (ListProcessorTypesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/processorTypes" - }; - option (google.api.method_signature) = "parent"; - } - - // Lists all processors which belong to this project. - rpc ListProcessors(ListProcessorsRequest) returns (ListProcessorsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/processors" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a processor detail. - rpc GetProcessor(GetProcessorRequest) returns (Processor) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/processors/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets a processor version detail. - rpc GetProcessorVersion(GetProcessorVersionRequest) returns (ProcessorVersion) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all versions of a processor. - rpc ListProcessorVersions(ListProcessorVersionsRequest) returns (ListProcessorVersionsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/processors/*}/processorVersions" - }; - option (google.api.method_signature) = "parent"; - } - - // Deletes the processor version, all artifacts under the processor version - // will be deleted. - rpc DeleteProcessorVersion(DeleteProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "DeleteProcessorVersionMetadata" - }; - } - - // Deploys the processor version. - rpc DeployProcessorVersion(DeployProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:deploy" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "DeployProcessorVersionResponse" - metadata_type: "DeployProcessorVersionMetadata" - }; - } - - // Undeploys the processor version. - rpc UndeployProcessorVersion(UndeployProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:undeploy" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "UndeployProcessorVersionResponse" - metadata_type: "UndeployProcessorVersionMetadata" - }; - } - - // Creates a processor from the type processor that the user chose. - // The processor will be at "ENABLED" state by default after its creation. - rpc CreateProcessor(CreateProcessorRequest) returns (Processor) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/processors" - body: "processor" - }; - option (google.api.method_signature) = "parent,processor"; - } - - // Deletes the processor, unloads all deployed model artifacts if it was - // enabled and then deletes all artifacts associated with this processor. - rpc DeleteProcessor(DeleteProcessorRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/processors/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "DeleteProcessorMetadata" - }; - } - - // Enables a processor - rpc EnableProcessor(EnableProcessorRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*}:enable" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "EnableProcessorResponse" - metadata_type: "EnableProcessorMetadata" - }; - } - - // Disables a processor - rpc DisableProcessor(DisableProcessorRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*}:disable" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "DisableProcessorResponse" - metadata_type: "DisableProcessorMetadata" - }; - } - - // Set the default (active) version of a [Processor][google.cloud.documentai.v1.Processor] that will be used in - // [ProcessDocument][google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument] and - // [BatchProcessDocuments][google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments]. - rpc SetDefaultProcessorVersion(SetDefaultProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{processor=projects/*/locations/*/processors/*}:setDefaultProcessorVersion" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "SetDefaultProcessorVersionResponse" - metadata_type: "SetDefaultProcessorVersionMetadata" - }; - } - - // Send a document for Human Review. The input document should be processed by - // the specified processor. - rpc ReviewDocument(ReviewDocumentRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{human_review_config=projects/*/locations/*/processors/*/humanReviewConfig}:reviewDocument" - body: "*" - }; - option (google.api.method_signature) = "human_review_config"; - option (google.longrunning.operation_info) = { - response_type: "ReviewDocumentResponse" - metadata_type: "ReviewDocumentOperationMetadata" - }; - } -} - -// Request message for the process document method. -message ProcessRequest { - // The document payload. - oneof source { - // An inline document proto. - Document inline_document = 4; - - // A raw document content (bytes). - RawDocument raw_document = 5; - } - - // Required. The resource name of the [Processor][google.cloud.documentai.v1.Processor] or - // [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] - // to use for processing. If a [Processor][google.cloud.documentai.v1.Processor] is specified, the server will use - // its [default version][google.cloud.documentai.v1.Processor.default_processor_version]. Format: - // `projects/{project}/locations/{location}/processors/{processor}`, or - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "*" - } - ]; - - // Whether Human Review feature should be skipped for this request. Default to - // false. - bool skip_human_review = 3; - - // Specifies which fields to include in ProcessResponse's document. - // Only supports top level document and pages field so it must be in the form - // of `{document_field_name}` or `pages.{page_field_name}`. - google.protobuf.FieldMask field_mask = 6; -} - -// The status of human review on a processed document. -message HumanReviewStatus { - // The final state of human review on a processed document. - enum State { - // Human review state is unspecified. Most likely due to an internal error. - STATE_UNSPECIFIED = 0; - - // Human review is skipped for the document. This can happen because human - // review is not enabled on the processor or the processing request has - // been set to skip this document. - SKIPPED = 1; - - // Human review validation is triggered and passed, so no review is needed. - VALIDATION_PASSED = 2; - - // Human review validation is triggered and the document is under review. - IN_PROGRESS = 3; - - // Some error happened during triggering human review, see the - // [state_message] for details. - ERROR = 4; - } - - // The state of human review on the processing request. - State state = 1; - - // A message providing more details about the human review state. - string state_message = 2; - - // The name of the operation triggered by the processed document. This field - // is populated only when the [state] is [HUMAN_REVIEW_IN_PROGRESS]. It has - // the same response type and metadata as the long running operation returned - // by [ReviewDocument] method. - string human_review_operation = 3; -} - -// Response message for the process document method. -message ProcessResponse { - // The document payload, will populate fields based on the processor's - // behavior. - Document document = 1; - - // The status of human review on the processed document. - HumanReviewStatus human_review_status = 3; -} - -// Request message for batch process document method. -message BatchProcessRequest { - // Required. The resource name of [Processor][google.cloud.documentai.v1.Processor] or - // [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion]. - // Format: `projects/{project}/locations/{location}/processors/{processor}`, - // or - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "*" - } - ]; - - // The input documents for batch process. - BatchDocumentsInputConfig input_documents = 5; - - // The overall output config for batch process. - DocumentOutputConfig document_output_config = 6; - - // Whether Human Review feature should be skipped for this request. Default to - // false. - bool skip_human_review = 4; -} - -// Response message for batch process document method. -message BatchProcessResponse { - -} - -// The long running operation metadata for batch process method. -message BatchProcessMetadata { - // The status of a each individual document in the batch process. - message IndividualProcessStatus { - // The source of the document, same as the [input_gcs_source] field in the - // request when the batch process started. The batch process is started by - // take snapshot of that document, since a user can move or change that - // document during the process. - string input_gcs_source = 1; - - // The status processing the document. - google.rpc.Status status = 2; - - // The output_gcs_destination (in the request as `output_gcs_destination`) - // of the processed document if it was successful, otherwise empty. - string output_gcs_destination = 3; - - // The status of human review on the processed document. - HumanReviewStatus human_review_status = 5; - } - - // Possible states of the batch processing operation. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // Request operation is waiting for scheduling. - WAITING = 1; - - // Request is being processed. - RUNNING = 2; - - // The batch processing completed successfully. - SUCCEEDED = 3; - - // The batch processing was being cancelled. - CANCELLING = 4; - - // The batch processing was cancelled. - CANCELLED = 5; - - // The batch processing has failed. - FAILED = 6; - } - - // The state of the current batch processing. - State state = 1; - - // A message providing more details about the current state of processing. - // For example, the error message if the operation is failed. - string state_message = 2; - - // The creation time of the operation. - google.protobuf.Timestamp create_time = 3; - - // The last update time of the operation. - google.protobuf.Timestamp update_time = 4; - - // The list of response details of each document. - repeated IndividualProcessStatus individual_process_statuses = 5; -} - -// Request message for fetch processor types. -message FetchProcessorTypesRequest { - // Required. The project of processor type to list. - // The available processor types may depend on the allow-listing on projects. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/ProcessorType" - } - ]; -} - -// Response message for fetch processor types. -message FetchProcessorTypesResponse { - // The list of processor types. - repeated ProcessorType processor_types = 1; -} - -// Request message for list processor types. -message ListProcessorTypesRequest { - // Required. The location of processor type to list. - // The available processor types may depend on the allow-listing on projects. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/ProcessorType" - } - ]; - - // The maximum number of processor types to return. - // If unspecified, at most 100 processor types will be returned. - // The maximum value is 500; values above 500 will be coerced to 500. - int32 page_size = 2; - - // Used to retrieve the next page of results, empty if at the end of the list. - string page_token = 3; -} - -// Response message for list processor types. -message ListProcessorTypesResponse { - // The processor types. - repeated ProcessorType processor_types = 1; - - // Points to the next page, otherwise empty. - string next_page_token = 2; -} - -// Request message for list all processors belongs to a project. -message ListProcessorsRequest { - // Required. The parent (project and location) which owns this collection of Processors. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/Processor" - } - ]; - - // The maximum number of processors to return. - // If unspecified, at most 50 processors will be returned. - // The maximum value is 100; values above 100 will be coerced to 100. - int32 page_size = 2; - - // We will return the processors sorted by creation time. The page token - // will point to the next processor. - string page_token = 3; -} - -// Response message for list processors. -message ListProcessorsResponse { - // The list of processors. - repeated Processor processors = 1; - - // Points to the next processor, otherwise empty. - string next_page_token = 2; -} - -// Request message for get processor. -message GetProcessorRequest { - // Required. The processor resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// Request message for get processor version. -message GetProcessorVersionRequest { - // Required. The processor resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Request message for list all processor versions belongs to a processor. -message ListProcessorVersionsRequest { - // Required. The parent (project, location and processor) to list all versions. - // Format: `projects/{project}/locations/{location}/processors/{processor}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/ProcessorVersion" - } - ]; - - // The maximum number of processor versions to return. - // If unspecified, at most 10 processor versions will be returned. - // The maximum value is 20; values above 20 will be coerced to 20. - int32 page_size = 2; - - // We will return the processor versions sorted by creation time. The page - // token will point to the next processor version. - string page_token = 3; -} - -// Response message for list processors. -message ListProcessorVersionsResponse { - // The list of processors. - repeated ProcessorVersion processor_versions = 1; - - // Points to the next processor, otherwise empty. - string next_page_token = 2; -} - -// Request message for the delete processor version method. -message DeleteProcessorVersionRequest { - // Required. The processor version resource name to be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// The long running operation metadata for delete processor version method. -message DeleteProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for the deploy processor version method. -message DeployProcessorVersionRequest { - // Required. The processor version resource name to be deployed. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Response message for the deploy processor version method. -message DeployProcessorVersionResponse { - -} - -// The long running operation metadata for deploy processor version method. -message DeployProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for the undeploy processor version method. -message UndeployProcessorVersionRequest { - // Required. The processor version resource name to be undeployed. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Response message for the undeploy processor version method. -message UndeployProcessorVersionResponse { - -} - -// The long running operation metadata for the undeploy processor version -// method. -message UndeployProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for create a processor. Notice this request is sent to -// a regionalized backend service, and if the processor type is not available -// on that region, the creation will fail. -message CreateProcessorRequest { - // Required. The parent (project and location) under which to create the processor. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/Processor" - } - ]; - - // Required. The processor to be created, requires [processor_type] and [display_name] - // to be set. Also, the processor is under CMEK if CMEK fields are set. - Processor processor = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for the delete processor method. -message DeleteProcessorRequest { - // Required. The processor resource name to be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// The long running operation metadata for delete processor method. -message DeleteProcessorMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} - -// Request message for the enable processor method. -message EnableProcessorRequest { - // Required. The processor resource name to be enabled. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// Response message for the enable processor method. -// Intentionally empty proto for adding fields in future. -message EnableProcessorResponse { - -} - -// The long running operation metadata for enable processor method. -message EnableProcessorMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} - -// Request message for the disable processor method. -message DisableProcessorRequest { - // Required. The processor resource name to be disabled. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// Response message for the disable processor method. -// Intentionally empty proto for adding fields in future. -message DisableProcessorResponse { - -} - -// The long running operation metadata for disable processor method. -message DisableProcessorMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} - -// Request message for the set default processor version method. -message SetDefaultProcessorVersionRequest { - // Required. The resource name of the [Processor][google.cloud.documentai.v1.Processor] to change default version. - string processor = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; - - // Required. The resource name of child [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] to use as default. - // Format: - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` - string default_processor_version = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Response message for set default processor version method. -message SetDefaultProcessorVersionResponse { - -} - -// The long running operation metadata for set default processor version -// method. -message SetDefaultProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for review document method. -message ReviewDocumentRequest { - // The priority level of the human review task. - enum Priority { - // The default priority level. - DEFAULT = 0; - - // The urgent priority level. The labeling manager should allocate labeler - // resource to the urgent task queue to respect this priority level. - URGENT = 1; - } - - // The document payload. - oneof source { - // An inline document proto. - Document inline_document = 4; - } - - // Required. The resource name of the HumanReviewConfig that the document will be - // reviewed with. - string human_review_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/HumanReviewConfig" - } - ]; - - // Whether the validation should be performed on the ad-hoc review request. - bool enable_schema_validation = 3; - - // The priority of the human review task. - Priority priority = 5; - - // The document schema of the human review task. - DocumentSchema document_schema = 6; -} - -// Response message for review document method. -message ReviewDocumentResponse { - // Possible states of the review operation. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // The review operation is rejected by the reviewer. - REJECTED = 1; - - // The review operation is succeeded. - SUCCEEDED = 2; - } - - // The Cloud Storage uri for the human reviewed document if the review is - // succeeded. - string gcs_destination = 1; - - // The state of the review operation. - State state = 2; - - // The reason why the review is rejected by reviewer. - string rejection_reason = 3; -} - -// The long running operation metadata for review document method. -message ReviewDocumentOperationMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; - - // The Crowd Compute question ID. - string question_id = 6; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_schema.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_schema.proto deleted file mode 100644 index ceb25a1d69a..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/document_schema.proto +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiDocumentSchema"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// The schema defines the output of the processed document by a processor. -message DocumentSchema { - // EntityType is the wrapper of a label of the corresponding model with - // detailed attributes and limitations for entity-based processors. Multiple - // types can also compose a dependency tree to represent nested types. - message EntityType { - // Defines the a list of enum values. - message EnumValues { - // The individual values that this enum values type can include. - repeated string values = 1; - } - - // Defines properties that can be part of the entity type. - message Property { - // Types of occurrences of the entity type in the document. Note: this - // represents the number of instances of an entity types, not number of - // mentions of a given entity instance. - enum OccurrenceType { - // Unspecified occurrence type. - OCCURRENCE_TYPE_UNSPECIFIED = 0; - - // There will be zero or one instance of this entity type. - OPTIONAL_ONCE = 1; - - // The entity type will appear zero or multiple times. - OPTIONAL_MULTIPLE = 2; - - // The entity type will only appear exactly once. - REQUIRED_ONCE = 3; - - // The entity type will appear once or more times. - REQUIRED_MULTIPLE = 4; - } - - // The name of the property. Follows the same guidelines as the - // EntityType name. - string name = 1; - - // A reference to the value type of the property. This type is subject - // to the same conventions as the `Entity.base_types` field. - string value_type = 2; - - // Occurrence type limits the number of instances an entity type appears - // in the document. - OccurrenceType occurrence_type = 3; - } - - oneof value_source { - // If specified, lists all the possible values for this entity. This - // should not be more than a handful of values. If the number of values - // is >10 or could change frequently use the `EntityType.value_ontology` - // field and specify a list of all possible values in a value ontology - // file. - EnumValues enum_values = 14; - } - - // User defined name for the type. - string display_name = 13; - - // Name of the type. It must be unique within the schema file and - // cannot be a 'Common Type'. Besides that we use the following naming - // conventions: - // - // - *use `snake_casing`* - // - name matching is case-insensitive - // - Maximum 64 characters. - // - Must start with a letter. - // - Allowed characters: ASCII letters `[a-z0-9_-]`. (For backward - // compatibility internal infrastructure and tooling can handle any ascii - // character) - // - The `/` is sometimes used to denote a property of a type. For example - // `line_item/amount`. This convention is deprecated, but will still be - // honored for backward compatibility. - string name = 1; - - // The entity type that this type is derived from. For now, one and only - // one should be set. - repeated string base_types = 2; - - // Describing the nested structure, or composition of an entity. - repeated Property properties = 6; - } - - // Metadata for global schema behavior. - message Metadata { - // If true, a `document` entity type can be applied to subdocument ( - // splitting). Otherwise, it can only be applied to the entire document - // (classification). - bool document_splitter = 1; - - // If true, on a given page, there can be multiple `document` annotations - // covering it. - bool document_allow_multiple_labels = 2; - - // If set, all the nested entities must be prefixed with the parents. - bool prefixed_naming_on_properties = 6; - - // If set, we will skip the naming format validation in the schema. So the - // string values in `DocumentSchema.EntityType.name` and - // `DocumentSchema.EntityType.Property.name` will not be checked. - bool skip_naming_validation = 7; - } - - // Display name to show to users. - string display_name = 1; - - // Description of the schema. - string description = 2; - - // Entity types of the schema. - repeated EntityType entity_types = 3; - - // Metadata of the schema. - Metadata metadata = 4; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/geometry.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/geometry.proto deleted file mode 100644 index 7471ef01247..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/geometry.proto +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.documentai.v1; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// A vertex represents a 2D point in the image. -// NOTE: the vertex coordinates are in the same scale as the original image. -message Vertex { - // X coordinate. - int32 x = 1; - - // Y coordinate (starts from the top of the image). - int32 y = 2; -} - -// A vertex represents a 2D point in the image. -// NOTE: the normalized vertex coordinates are relative to the original image -// and range from 0 to 1. -message NormalizedVertex { - // X coordinate. - float x = 1; - - // Y coordinate (starts from the top of the image). - float y = 2; -} - -// A bounding polygon for the detected image annotation. -message BoundingPoly { - // The bounding polygon vertices. - repeated Vertex vertices = 1; - - // The bounding polygon normalized vertices. - repeated NormalizedVertex normalized_vertices = 2; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/operation_metadata.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/operation_metadata.proto deleted file mode 100644 index 5698b0a4f3c..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/operation_metadata.proto +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "OperationMetadataProto"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// The common metadata for long running operations. -message CommonOperationMetadata { - // State of the longrunning operation. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // Operation is still running. - RUNNING = 1; - - // Operation is being cancelled. - CANCELLING = 2; - - // Operation succeeded. - SUCCEEDED = 3; - - // Operation failed. - FAILED = 4; - - // Operation is cancelled. - CANCELLED = 5; - } - - // The state of the operation. - State state = 1; - - // A message providing more details about the current state of processing. - string state_message = 2; - - // A related resource to this operation. - string resource = 5; - - // The creation time of the operation. - google.protobuf.Timestamp create_time = 3; - - // The last update time of the operation. - google.protobuf.Timestamp update_time = 4; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor.proto deleted file mode 100644 index 3ffe6927df9..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor.proto +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/documentai/v1/document_schema.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProcessor"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// A processor version is an implementation of a processor. Each processor -// can have multiple versions, pre-trained by Google internally or up-trained -// by the customer. At a time, a processor can only have one default version -// version. So the processor's behavior (when processing documents) is defined -// by a default version -message ProcessorVersion { - option (google.api.resource) = { - type: "documentai.googleapis.com/ProcessorVersion" - pattern: "projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}" - }; - - // Information about the upcoming deprecation of this processor version. - message DeprecationInfo { - // The time at which this processor version will be deprecated. - google.protobuf.Timestamp deprecation_time = 1; - - // If set, the processor version that will be used as a replacement. - string replacement_processor_version = 2 [(google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - }]; - } - - // The possible states of the processor version. - enum State { - // The processor version is in an unspecified state. - STATE_UNSPECIFIED = 0; - - // The processor version is deployed and can be used for processing. - DEPLOYED = 1; - - // The processor version is being deployed. - DEPLOYING = 2; - - // The processor version is not deployed and cannot be used for processing. - UNDEPLOYED = 3; - - // The processor version is being undeployed. - UNDEPLOYING = 4; - - // The processor version is being created. - CREATING = 5; - - // The processor version is being deleted. - DELETING = 6; - - // The processor version failed and is in an indeterminate state. - FAILED = 7; - } - - // The resource name of the processor version. - // Format: - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}` - string name = 1; - - // The display name of the processor version. - string display_name = 2; - - // The schema of the processor version. Describes the output. - DocumentSchema document_schema = 12; - - // The state of the processor version. - State state = 6; - - // The time the processor version was created. - google.protobuf.Timestamp create_time = 7; - - // The KMS key name used for encryption. - string kms_key_name = 9; - - // The KMS key version with which data is encrypted. - string kms_key_version_name = 10; - - // Denotes that this ProcessorVersion is managed by google. - bool google_managed = 11; - - // If set, information about the eventual deprecation of this version. - DeprecationInfo deprecation_info = 13; -} - -// The first-class citizen for Document AI. Each processor defines how to -// extract structural information from a document. -message Processor { - option (google.api.resource) = { - type: "documentai.googleapis.com/Processor" - pattern: "projects/{project}/locations/{location}/processors/{processor}" - }; - - // The possible states of the processor. - enum State { - // The processor is in an unspecified state. - STATE_UNSPECIFIED = 0; - - // The processor is enabled, i.e., has an enabled version which can - // currently serve processing requests and all the feature dependencies have - // been successfully initialized. - ENABLED = 1; - - // The processor is disabled. - DISABLED = 2; - - // The processor is being enabled, will become `ENABLED` if successful. - ENABLING = 3; - - // The processor is being disabled, will become `DISABLED` if successful. - DISABLING = 4; - - // The processor is being created, will become either `ENABLED` (for - // successful creation) or `FAILED` (for failed ones). - // Once a processor is in this state, it can then be used for document - // processing, but the feature dependencies of the processor might not be - // fully created yet. - CREATING = 5; - - // The processor failed during creation or initialization of feature - // dependencies. The user should delete the processor and recreate one as - // all the functionalities of the processor are disabled. - FAILED = 6; - - // The processor is being deleted, will be removed if successful. - DELETING = 7; - } - - // Output only. Immutable. The resource name of the processor. - // Format: `projects/{project}/locations/{location}/processors/{processor}` - string name = 1 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. - // To get a list of processors types, see - // [FetchProcessorTypes][google.cloud.documentai.v1.DocumentProcessorService.FetchProcessorTypes]. - string type = 2; - - // The display name of the processor. - string display_name = 3; - - // Output only. The state of the processor. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The default processor version. - string default_processor_version = 9 [(google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - }]; - - // Output only. Immutable. The http endpoint that can be called to invoke processing. - string process_endpoint = 6 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.field_behavior) = IMMUTABLE - ]; - - // The time the processor was created. - google.protobuf.Timestamp create_time = 7; - - // The KMS key used for encryption/decryption in CMEK scenarios. - // See https://cloud.google.com/security-key-management. - string kms_key_name = 8; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor_type.proto b/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor_type.proto deleted file mode 100644 index 2c9ee923051..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/protos/google/cloud/documentai/v1/processor_type.proto +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// 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.documentai.v1; - -import "google/api/launch_stage.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProcessorType"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// A processor type is responsible for performing a certain document -// understanding task on a certain type of document. -message ProcessorType { - option (google.api.resource) = { - type: "documentai.googleapis.com/ProcessorType" - pattern: "projects/{project}/locations/{location}/processorTypes/{processor_type}" - }; - - // The location information about where the processor is available. - message LocationInfo { - // The location id, currently must be one of [us, eu]. - string location_id = 1; - } - - // The resource name of the processor type. - // Format: `projects/{project}/processorTypes/{processor_type}` - string name = 1; - - // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. - string type = 2; - - // The processor category, used by UI to group processor types. - string category = 3; - - // The locations in which this processor is available. - repeated LocationInfo available_locations = 4; - - // Whether the processor type allows creation. If true, users can create a - // processor of this processor type. Otherwise, users need to request access. - bool allow_creation = 6; - - // Launch stage of the processor type - google.api.LaunchStage launch_stage = 8; -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.create_document_link.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.create_document_link.js deleted file mode 100644 index d04c5515e32..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.create_document_link.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, documentLink) { - // [START contentwarehouse_v1_generated_DocumentLinkService_CreateDocumentLink_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Parent of the document-link to be created. - * parent of document-link should be a document. - * Format: - * projects/{project_number}/locations/{location}/documents/{source_document_id}. - */ - // const parent = 'abc123' - /** - * Required. Document links associated with the source documents (source_document_id). - */ - // const documentLink = {} - /** - * The meta information collected about the document creator, used to enforce - * access control for the service. - */ - // const requestMetadata = {} - - // Imports the Contentwarehouse library - const {DocumentLinkServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentLinkServiceClient(); - - async function callCreateDocumentLink() { - // Construct request - const request = { - parent, - documentLink, - }; - - // Run request - const response = await contentwarehouseClient.createDocumentLink(request); - console.log(response); - } - - callCreateDocumentLink(); - // [END contentwarehouse_v1_generated_DocumentLinkService_CreateDocumentLink_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.delete_document_link.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.delete_document_link.js deleted file mode 100644 index f068f8a50e4..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.delete_document_link.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START contentwarehouse_v1_generated_DocumentLinkService_DeleteDocumentLink_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 document-link to be deleted. - * Format: - * projects/{project_number}/locations/{location}/documents/{source_document_id}/documentLinks/{document_link_id}. - */ - // const name = 'abc123' - /** - * The meta information collected about the document creator, used to enforce - * access control for the service. - */ - // const requestMetadata = {} - - // Imports the Contentwarehouse library - const {DocumentLinkServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentLinkServiceClient(); - - async function callDeleteDocumentLink() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await contentwarehouseClient.deleteDocumentLink(request); - console.log(response); - } - - callDeleteDocumentLink(); - // [END contentwarehouse_v1_generated_DocumentLinkService_DeleteDocumentLink_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_sources.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_sources.js deleted file mode 100644 index 8796f413cdc..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_sources.js +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START contentwarehouse_v1_generated_DocumentLinkService_ListLinkedSources_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 document, for which all source links are returned. - * Format: - * projects/{project_number}/locations/{location}/documents/{source_document_id}. - */ - // const parent = 'abc123' - /** - * The maximum number of document-links to return. The service may return - * fewer than this value. - * If unspecified, at most 50 document-links will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - */ - // const pageSize = 1234 - /** - * A page token, received from a previous `ListLinkedSources` call. - * Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to `ListLinkedSources` - * must match the call that provided the page token. - */ - // const pageToken = 'abc123' - /** - * The meta information collected about the document creator, used to enforce - * access control for the service. - */ - // const requestMetadata = {} - - // Imports the Contentwarehouse library - const {DocumentLinkServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentLinkServiceClient(); - - async function callListLinkedSources() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await contentwarehouseClient.listLinkedSourcesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListLinkedSources(); - // [END contentwarehouse_v1_generated_DocumentLinkService_ListLinkedSources_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_targets.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_targets.js deleted file mode 100644 index f15e3276594..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_link_service.list_linked_targets.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START contentwarehouse_v1_generated_DocumentLinkService_ListLinkedTargets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 document, for which all target links are returned. - * Format: - * projects/{project_number}/locations/{location}/documents/{target_document_id}. - */ - // const parent = 'abc123' - /** - * The meta information collected about the document creator, used to enforce - * access control for the service. - */ - // const requestMetadata = {} - - // Imports the Contentwarehouse library - const {DocumentLinkServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentLinkServiceClient(); - - async function callListLinkedTargets() { - // Construct request - const request = { - parent, - }; - - // Run request - const response = await contentwarehouseClient.listLinkedTargets(request); - console.log(response); - } - - callListLinkedTargets(); - // [END contentwarehouse_v1_generated_DocumentLinkService_ListLinkedTargets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.create_document_schema.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.create_document_schema.js deleted file mode 100644 index c91a34faf6e..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.create_document_schema.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, documentSchema) { - // [START contentwarehouse_v1_generated_DocumentSchemaService_CreateDocumentSchema_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 name. - */ - // const parent = 'abc123' - /** - * Required. The document schema to create. - */ - // const documentSchema = {} - - // Imports the Contentwarehouse library - const {DocumentSchemaServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentSchemaServiceClient(); - - async function callCreateDocumentSchema() { - // Construct request - const request = { - parent, - documentSchema, - }; - - // Run request - const response = await contentwarehouseClient.createDocumentSchema(request); - console.log(response); - } - - callCreateDocumentSchema(); - // [END contentwarehouse_v1_generated_DocumentSchemaService_CreateDocumentSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.delete_document_schema.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.delete_document_schema.js deleted file mode 100644 index f85067dd155..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.delete_document_schema.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START contentwarehouse_v1_generated_DocumentSchemaService_DeleteDocumentSchema_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 document schema to delete. - */ - // const name = 'abc123' - - // Imports the Contentwarehouse library - const {DocumentSchemaServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentSchemaServiceClient(); - - async function callDeleteDocumentSchema() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await contentwarehouseClient.deleteDocumentSchema(request); - console.log(response); - } - - callDeleteDocumentSchema(); - // [END contentwarehouse_v1_generated_DocumentSchemaService_DeleteDocumentSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.get_document_schema.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.get_document_schema.js deleted file mode 100644 index 005eb89783e..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.get_document_schema.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START contentwarehouse_v1_generated_DocumentSchemaService_GetDocumentSchema_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 document schema to retrieve. - */ - // const name = 'abc123' - - // Imports the Contentwarehouse library - const {DocumentSchemaServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentSchemaServiceClient(); - - async function callGetDocumentSchema() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await contentwarehouseClient.getDocumentSchema(request); - console.log(response); - } - - callGetDocumentSchema(); - // [END contentwarehouse_v1_generated_DocumentSchemaService_GetDocumentSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.list_document_schemas.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.list_document_schemas.js deleted file mode 100644 index 5bff35fb80a..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.list_document_schemas.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START contentwarehouse_v1_generated_DocumentSchemaService_ListDocumentSchemas_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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, which owns this collection of document schemas. - * Format: projects/{project_number}/locations/{location}. - */ - // const parent = 'abc123' - /** - * The maximum number of document schemas to return. The service may return - * fewer than this value. - * If unspecified, at most 50 document schemas will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - */ - // const pageSize = 1234 - /** - * A page token, received from a previous `ListDocumentSchemas` call. - * Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to `ListDocumentSchemas` - * must match the call that provided the page token. - */ - // const pageToken = 'abc123' - - // Imports the Contentwarehouse library - const {DocumentSchemaServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentSchemaServiceClient(); - - async function callListDocumentSchemas() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await contentwarehouseClient.listDocumentSchemasAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListDocumentSchemas(); - // [END contentwarehouse_v1_generated_DocumentSchemaService_ListDocumentSchemas_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.update_document_schema.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.update_document_schema.js deleted file mode 100644 index 89fe9e123cb..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_schema_service.update_document_schema.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, documentSchema) { - // [START contentwarehouse_v1_generated_DocumentSchemaService_UpdateDocumentSchema_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 document schema to update. - * Format: - * projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. - */ - // const name = 'abc123' - /** - * Required. The document schema to update with. - */ - // const documentSchema = {} - - // Imports the Contentwarehouse library - const {DocumentSchemaServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentSchemaServiceClient(); - - async function callUpdateDocumentSchema() { - // Construct request - const request = { - name, - documentSchema, - }; - - // Run request - const response = await contentwarehouseClient.updateDocumentSchema(request); - console.log(response); - } - - callUpdateDocumentSchema(); - // [END contentwarehouse_v1_generated_DocumentSchemaService_UpdateDocumentSchema_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.create_document.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.create_document.js deleted file mode 100644 index 35fe66612ea..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.create_document.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, document) { - // [START contentwarehouse_v1_generated_DocumentService_CreateDocument_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent name. - * Format: projects/{project_number}/locations/{location}. - */ - // const parent = 'abc123' - /** - * Required. The document to create. - */ - // const document = {} - /** - * The meta information collected about the end user, used to enforce access - * control for the service. - */ - // const requestMetadata = {} - /** - * Default document policy during creation. Conditions defined in the policy - * will be ignored. - */ - // const policy = {} - /** - * Request Option for processing Cloud AI Document in CW Document. - */ - // const cloudAiDocumentOption = {} - /** - * Field mask for creating Document fields. If mask path is empty, - * it means all fields are masked. - * For the `FieldMask` definition, - * see - * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - */ - // const createMask = {} - - // Imports the Contentwarehouse library - const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentServiceClient(); - - async function callCreateDocument() { - // Construct request - const request = { - parent, - document, - }; - - // Run request - const response = await contentwarehouseClient.createDocument(request); - console.log(response); - } - - callCreateDocument(); - // [END contentwarehouse_v1_generated_DocumentService_CreateDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.delete_document.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.delete_document.js deleted file mode 100644 index 6df73e989bd..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.delete_document.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START contentwarehouse_v1_generated_DocumentService_DeleteDocument_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the document to delete. - * Format: - * projects/{project_number}/locations/{location}/documents/{document_id} - * or - * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. - */ - // const name = 'abc123' - /** - * The meta information collected about the end user, used to enforce access - * control for the service. - */ - // const requestMetadata = {} - - // Imports the Contentwarehouse library - const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentServiceClient(); - - async function callDeleteDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await contentwarehouseClient.deleteDocument(request); - console.log(response); - } - - callDeleteDocument(); - // [END contentwarehouse_v1_generated_DocumentService_DeleteDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.fetch_acl.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.fetch_acl.js deleted file mode 100644 index 78658a78264..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.fetch_acl.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource) { - // [START contentwarehouse_v1_generated_DocumentService_FetchAcl_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. REQUIRED: The resource for which the policy is being requested. - * Format for document: - * projects/{project_number}/locations/{location}/documents/{document_id}. - * Format for project: projects/{project_number}. - */ - // const resource = 'abc123' - /** - * The meta information collected about the end user, used to enforce access - * control for the service. - */ - // const requestMetadata = {} - /** - * For Get Project ACL only. Authorization check for end user will be ignored - * when project_owner=true. - */ - // const projectOwner = true - - // Imports the Contentwarehouse library - const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentServiceClient(); - - async function callFetchAcl() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await contentwarehouseClient.fetchAcl(request); - console.log(response); - } - - callFetchAcl(); - // [END contentwarehouse_v1_generated_DocumentService_FetchAcl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.get_document.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.get_document.js deleted file mode 100644 index 02c64981e05..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.get_document.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START contentwarehouse_v1_generated_DocumentService_GetDocument_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the document to retrieve. - * Format: - * projects/{project_number}/locations/{location}/documents/{document_id} or - * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. - */ - // const name = 'abc123' - /** - * The meta information collected about the end user, used to enforce access - * control for the service. - */ - // const requestMetadata = {} - - // Imports the Contentwarehouse library - const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentServiceClient(); - - async function callGetDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await contentwarehouseClient.getDocument(request); - console.log(response); - } - - callGetDocument(); - // [END contentwarehouse_v1_generated_DocumentService_GetDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.search_documents.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.search_documents.js deleted file mode 100644 index b98b2b52310..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.search_documents.js +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START contentwarehouse_v1_generated_DocumentService_SearchDocuments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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, which owns this collection of documents. - * Format: projects/{project_number}/locations/{location}. - */ - // const parent = 'abc123' - /** - * The meta information collected about the end user, used to enforce access - * control and improve the search quality of the service. - */ - // const requestMetadata = {} - /** - * Query used to search against documents (keyword, filters, etc.). - */ - // const documentQuery = {} - /** - * An integer that specifies the current offset (that is, starting result - * location, amongst the documents deemed by the API as relevant) in search - * results. This field is only considered if page_token google.cloud.contentwarehouse.v1.SearchDocumentsRequest.page_token is unset. - * The maximum allowed value is 5000. Otherwise an error is thrown. - * For example, 0 means to return results starting from the first matching - * document, and 10 means to return from the 11th document. This can be used - * for pagination, (for example, pageSize = 10 and offset = 10 means to return - * from the second page). - */ - // const offset = 1234 - /** - * A limit on the number of documents returned in the search results. - * Increasing this value above the default value of 10 can increase search - * response time. The value can be between 1 and 100. - */ - // const pageSize = 1234 - /** - * The token specifying the current offset within search results. - * See SearchDocumentsResponse.next_page_token google.cloud.contentwarehouse.v1.SearchDocumentsResponse.next_page_token for an explanation of how - * to obtain the next set of query results. - */ - // const pageToken = 'abc123' - /** - * The criteria determining how search results are sorted. For non-empty - * query, default is `"relevance desc"`. For empty query, default is - * `"upload_date desc"`. - * Supported options are: - * * `"relevance desc"`: By relevance descending, as determined by the API - * algorithms. - * * `"upload_date desc"`: By upload date descending. - * * `"upload_date"`: By upload date ascending. - * * `"update_date desc"`: By last updated date descending. - * * `"update_date"`: By last updated date ascending. - */ - // const orderBy = 'abc123' - /** - * An expression specifying a histogram request against matching - * documents. Expression syntax is an aggregation function call with - * histogram facets and other options. - * The following aggregation functions are supported: - * * `count(string_histogram_facet)`: Count the number of matching entities - * for each distinct attribute value. - * Data types: - * * Histogram facet (aka filterable properties): Facet names with format - * <schema id>.<facet>. Facets will have the - * format of: `[a-zA-Z][a-zA-Z0-9_:/-.]`. If the facet is a child - * facet, then the parent hierarchy needs to be specified separated by - * dots in the prefix after the schema id. Thus, the format for a multi- - * level facet is: <schema id>.<parent facet name>. - * <child facet name>. Example: - * schema123.root_parent_facet.middle_facet.child_facet - * * DocumentSchemaId: (with no schema id prefix) to get - * histograms for each document type (returns the schema id path, e.g. - * projects/12345/locations/us-west/documentSchemas/abc123). - * Example expression: - * * Document type counts: - * count('DocumentSchemaId') - * * For schema id, abc123, get the counts for MORTGAGE_TYPE: - * count('abc123.MORTGAGE_TYPE') - */ - // const histogramQueries = 1234 - /** - * Optional. Controls if the search document request requires the return of a total size - * of matched documents. See SearchDocumentsResponse.total_size google.cloud.contentwarehouse.v1.SearchDocumentsResponse.total_size. - * Enabling this flag may adversely impact performance. Hint: If this is - * used with pagination, set this flag on the initial query but set this - * to false on subsequent page calls (keep the total count locally). - * Defaults to false. - */ - // const requireTotalSize = true - /** - * Experimental, do not use. - * The limit on the number of documents returned for the question-answering - * feature. To enable the question-answering feature, set - * DocumentQuery.is_nl_query to true. - */ - // const qaSizeLimit = 1234 - - // Imports the Contentwarehouse library - const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentServiceClient(); - - async function callSearchDocuments() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await contentwarehouseClient.searchDocumentsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchDocuments(); - // [END contentwarehouse_v1_generated_DocumentService_SearchDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.set_acl.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.set_acl.js deleted file mode 100644 index 1f7ab4b8157..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.set_acl.js +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource, policy) { - // [START contentwarehouse_v1_generated_DocumentService_SetAcl_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. REQUIRED: The resource for which the policy is being requested. - * Format for document: - * projects/{project_number}/locations/{location}/documents/{document_id}. - * Format for project: projects/{project_number}. - */ - // const resource = 'abc123' - /** - * Required. REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. - */ - // const policy = {} - /** - * The meta information collected about the end user, used to enforce access - * control for the service. - */ - // const requestMetadata = {} - /** - * For Set Project ACL only. Authorization check for end user will be ignored - * when project_owner=true. - */ - // const projectOwner = true - - // Imports the Contentwarehouse library - const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentServiceClient(); - - async function callSetAcl() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await contentwarehouseClient.setAcl(request); - console.log(response); - } - - callSetAcl(); - // [END contentwarehouse_v1_generated_DocumentService_SetAcl_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.update_document.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.update_document.js deleted file mode 100644 index cecb7def88f..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/document_service.update_document.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, document) { - // [START contentwarehouse_v1_generated_DocumentService_UpdateDocument_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the document to update. - * Format: - * projects/{project_number}/locations/{location}/documents/{document_id} - * or - * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. - */ - // const name = 'abc123' - /** - * Required. The document to update. - */ - // const document = {} - /** - * The meta information collected about the end user, used to enforce access - * control for the service. - */ - // const requestMetadata = {} - /** - * Request Option for processing Cloud AI Document in CW Document. - */ - // const cloudAiDocumentOption = {} - /** - * Options for the update operation. - */ - // const updateOptions = {} - - // Imports the Contentwarehouse library - const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new DocumentServiceClient(); - - async function callUpdateDocument() { - // Construct request - const request = { - name, - document, - }; - - // Run request - const response = await contentwarehouseClient.updateDocument(request); - console.log(response); - } - - callUpdateDocument(); - // [END contentwarehouse_v1_generated_DocumentService_UpdateDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.create_rule_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.create_rule_set.js deleted file mode 100644 index 367e9de519a..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.create_rule_set.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, ruleSet) { - // [START contentwarehouse_v1_generated_RuleSetService_CreateRuleSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 name. - * Format: projects/{project_number}/locations/{location}. - */ - // const parent = 'abc123' - /** - * Required. The rule set to create. - */ - // const ruleSet = {} - - // Imports the Contentwarehouse library - const {RuleSetServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new RuleSetServiceClient(); - - async function callCreateRuleSet() { - // Construct request - const request = { - parent, - ruleSet, - }; - - // Run request - const response = await contentwarehouseClient.createRuleSet(request); - console.log(response); - } - - callCreateRuleSet(); - // [END contentwarehouse_v1_generated_RuleSetService_CreateRuleSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.delete_rule_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.delete_rule_set.js deleted file mode 100644 index eb9996fd5c3..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.delete_rule_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START contentwarehouse_v1_generated_RuleSetService_DeleteRuleSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 rule set to delete. - * Format: - * projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. - */ - // const name = 'abc123' - - // Imports the Contentwarehouse library - const {RuleSetServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new RuleSetServiceClient(); - - async function callDeleteRuleSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await contentwarehouseClient.deleteRuleSet(request); - console.log(response); - } - - callDeleteRuleSet(); - // [END contentwarehouse_v1_generated_RuleSetService_DeleteRuleSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.get_rule_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.get_rule_set.js deleted file mode 100644 index 1b3b38f738c..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.get_rule_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START contentwarehouse_v1_generated_RuleSetService_GetRuleSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 rule set to retrieve. - * Format: - * projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. - */ - // const name = 'abc123' - - // Imports the Contentwarehouse library - const {RuleSetServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new RuleSetServiceClient(); - - async function callGetRuleSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await contentwarehouseClient.getRuleSet(request); - console.log(response); - } - - callGetRuleSet(); - // [END contentwarehouse_v1_generated_RuleSetService_GetRuleSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.list_rule_sets.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.list_rule_sets.js deleted file mode 100644 index 24ceab8ca14..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.list_rule_sets.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START contentwarehouse_v1_generated_RuleSetService_ListRuleSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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, which owns this collection of document. - * Format: projects/{project_number}/locations/{location}. - */ - // const parent = 'abc123' - /** - * The maximum number of rule sets to return. The service may return - * fewer than this value. - * If unspecified, at most 50 rule sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - */ - // const pageSize = 1234 - /** - * A page token, received from a previous `ListRuleSets` call. - * Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to `ListRuleSets` - * must match the call that provided the page token. - */ - // const pageToken = 'abc123' - - // Imports the Contentwarehouse library - const {RuleSetServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new RuleSetServiceClient(); - - async function callListRuleSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await contentwarehouseClient.listRuleSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListRuleSets(); - // [END contentwarehouse_v1_generated_RuleSetService_ListRuleSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.update_rule_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.update_rule_set.js deleted file mode 100644 index 359577ae72a..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/rule_set_service.update_rule_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, ruleSet) { - // [START contentwarehouse_v1_generated_RuleSetService_UpdateRuleSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 rule set to update. - * Format: - * projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. - */ - // const name = 'abc123' - /** - * Required. The rule set to update. - */ - // const ruleSet = {} - - // Imports the Contentwarehouse library - const {RuleSetServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new RuleSetServiceClient(); - - async function callUpdateRuleSet() { - // Construct request - const request = { - name, - ruleSet, - }; - - // Run request - const response = await contentwarehouseClient.updateRuleSet(request); - console.log(response); - } - - callUpdateRuleSet(); - // [END contentwarehouse_v1_generated_RuleSetService_UpdateRuleSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/snippet_metadata.google.cloud.contentwarehouse.v1.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/snippet_metadata.google.cloud.contentwarehouse.v1.json deleted file mode 100644 index ccbf22678d4..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/snippet_metadata.google.cloud.contentwarehouse.v1.json +++ /dev/null @@ -1,1231 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-contentwarehouse", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.contentwarehouse.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "contentwarehouse_v1_generated_DocumentLinkService_ListLinkedTargets_async", - "title": "DocumentLinkService listLinkedTargets Sample", - "origin": "API_DEFINITION", - "description": " Return all target document-links from the document.", - "canonical": true, - "file": "document_link_service.list_linked_targets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListLinkedTargets", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.ListLinkedTargets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.ListLinkedTargetsResponse", - "client": { - "shortName": "DocumentLinkServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkServiceClient" - }, - "method": { - "shortName": "ListLinkedTargets", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.ListLinkedTargets", - "service": { - "shortName": "DocumentLinkService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentLinkService_ListLinkedSources_async", - "title": "DocumentLinkService listLinkedSources Sample", - "origin": "API_DEFINITION", - "description": " Return all source document-links from the document.", - "canonical": true, - "file": "document_link_service.list_linked_sources.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 76, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListLinkedSources", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.ListLinkedSources", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.ListLinkedSourcesResponse", - "client": { - "shortName": "DocumentLinkServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkServiceClient" - }, - "method": { - "shortName": "ListLinkedSources", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.ListLinkedSources", - "service": { - "shortName": "DocumentLinkService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentLinkService_CreateDocumentLink_async", - "title": "DocumentLinkService createDocumentLink Sample", - "origin": "API_DEFINITION", - "description": " Create a link between a source document and a target document.", - "canonical": true, - "file": "document_link_service.create_document_link.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDocumentLink", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.CreateDocumentLink", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "document_link", - "type": ".google.cloud.contentwarehouse.v1.DocumentLink" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.DocumentLink", - "client": { - "shortName": "DocumentLinkServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkServiceClient" - }, - "method": { - "shortName": "CreateDocumentLink", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.CreateDocumentLink", - "service": { - "shortName": "DocumentLinkService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentLinkService_DeleteDocumentLink_async", - "title": "DocumentLinkService deleteDocumentLink Sample", - "origin": "API_DEFINITION", - "description": " Remove the link between the source and target documents.", - "canonical": true, - "file": "document_link_service.delete_document_link.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteDocumentLink", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.DeleteDocumentLink", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "DocumentLinkServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkServiceClient" - }, - "method": { - "shortName": "DeleteDocumentLink", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService.DeleteDocumentLink", - "service": { - "shortName": "DocumentLinkService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentLinkService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentSchemaService_CreateDocumentSchema_async", - "title": "DocumentLinkService createDocumentSchema Sample", - "origin": "API_DEFINITION", - "description": " Creates a document schema.", - "canonical": true, - "file": "document_schema_service.create_document_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDocumentSchema", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.CreateDocumentSchema", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "document_schema", - "type": ".google.cloud.contentwarehouse.v1.DocumentSchema" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.DocumentSchema", - "client": { - "shortName": "DocumentSchemaServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaServiceClient" - }, - "method": { - "shortName": "CreateDocumentSchema", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.CreateDocumentSchema", - "service": { - "shortName": "DocumentSchemaService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentSchemaService_UpdateDocumentSchema_async", - "title": "DocumentLinkService updateDocumentSchema Sample", - "origin": "API_DEFINITION", - "description": " Updates a Document Schema. Returns INVALID_ARGUMENT if the name of the Document Schema is non-empty and does not equal the existing name. Supports only appending new properties, adding new ENUM possible values, and updating the [EnumTypeOptions.validation_check_disabled][google.cloud.contentwarehouse.v1.EnumTypeOptions.validation_check_disabled] flag for ENUM possible values. Updating existing properties will result into INVALID_ARGUMENT.", - "canonical": true, - "file": "document_schema_service.update_document_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateDocumentSchema", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.UpdateDocumentSchema", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "document_schema", - "type": ".google.cloud.contentwarehouse.v1.DocumentSchema" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.DocumentSchema", - "client": { - "shortName": "DocumentSchemaServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaServiceClient" - }, - "method": { - "shortName": "UpdateDocumentSchema", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.UpdateDocumentSchema", - "service": { - "shortName": "DocumentSchemaService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentSchemaService_GetDocumentSchema_async", - "title": "DocumentLinkService getDocumentSchema Sample", - "origin": "API_DEFINITION", - "description": " Gets a document schema. Returns NOT_FOUND if the document schema does not exist.", - "canonical": true, - "file": "document_schema_service.get_document_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDocumentSchema", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.GetDocumentSchema", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.DocumentSchema", - "client": { - "shortName": "DocumentSchemaServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaServiceClient" - }, - "method": { - "shortName": "GetDocumentSchema", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.GetDocumentSchema", - "service": { - "shortName": "DocumentSchemaService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentSchemaService_DeleteDocumentSchema_async", - "title": "DocumentLinkService deleteDocumentSchema Sample", - "origin": "API_DEFINITION", - "description": " Deletes a document schema. Returns NOT_FOUND if the document schema does not exist. Returns BAD_REQUEST if the document schema has documents depending on it.", - "canonical": true, - "file": "document_schema_service.delete_document_schema.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteDocumentSchema", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.DeleteDocumentSchema", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "DocumentSchemaServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaServiceClient" - }, - "method": { - "shortName": "DeleteDocumentSchema", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.DeleteDocumentSchema", - "service": { - "shortName": "DocumentSchemaService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentSchemaService_ListDocumentSchemas_async", - "title": "DocumentLinkService listDocumentSchemas Sample", - "origin": "API_DEFINITION", - "description": " Lists document schemas.", - "canonical": true, - "file": "document_schema_service.list_document_schemas.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListDocumentSchemas", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.ListDocumentSchemas", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.ListDocumentSchemasResponse", - "client": { - "shortName": "DocumentSchemaServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaServiceClient" - }, - "method": { - "shortName": "ListDocumentSchemas", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService.ListDocumentSchemas", - "service": { - "shortName": "DocumentSchemaService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentSchemaService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentService_CreateDocument_async", - "title": "DocumentLinkService createDocument Sample", - "origin": "API_DEFINITION", - "description": " Creates a document.", - "canonical": true, - "file": "document_service.create_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 81, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDocument", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.CreateDocument", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "document", - "type": ".google.cloud.contentwarehouse.v1.Document" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "cloud_ai_document_option", - "type": ".google.cloud.contentwarehouse.v1.CloudAIDocumentOption" - }, - { - "name": "create_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.CreateDocumentResponse", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" - }, - "method": { - "shortName": "CreateDocument", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.CreateDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentService_GetDocument_async", - "title": "DocumentLinkService getDocument Sample", - "origin": "API_DEFINITION", - "description": " Gets a document. Returns NOT_FOUND if the document does not exist.", - "canonical": true, - "file": "document_service.get_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDocument", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.GetDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.Document", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" - }, - "method": { - "shortName": "GetDocument", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.GetDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentService_UpdateDocument_async", - "title": "DocumentLinkService updateDocument Sample", - "origin": "API_DEFINITION", - "description": " Updates a document. Returns INVALID_ARGUMENT if the name of the document is non-empty and does not equal the existing name.", - "canonical": true, - "file": "document_service.update_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateDocument", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.UpdateDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "document", - "type": ".google.cloud.contentwarehouse.v1.Document" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - }, - { - "name": "cloud_ai_document_option", - "type": ".google.cloud.contentwarehouse.v1.CloudAIDocumentOption" - }, - { - "name": "update_options", - "type": ".google.cloud.contentwarehouse.v1.UpdateOptions" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.UpdateDocumentResponse", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" - }, - "method": { - "shortName": "UpdateDocument", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.UpdateDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentService_DeleteDocument_async", - "title": "DocumentLinkService deleteDocument Sample", - "origin": "API_DEFINITION", - "description": " Deletes a document. Returns NOT_FOUND if the document does not exist.", - "canonical": true, - "file": "document_service.delete_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteDocument", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.DeleteDocument", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" - }, - "method": { - "shortName": "DeleteDocument", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.DeleteDocument", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentService_SearchDocuments_async", - "title": "DocumentLinkService searchDocuments Sample", - "origin": "API_DEFINITION", - "description": " Searches for documents using provided [SearchDocumentsRequest][google.cloud.contentwarehouse.v1.SearchDocumentsRequest]. This call only returns documents that the caller has permission to search against.", - "canonical": true, - "file": "document_service.search_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 143, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchDocuments", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.SearchDocuments", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - }, - { - "name": "document_query", - "type": ".google.cloud.contentwarehouse.v1.DocumentQuery" - }, - { - "name": "offset", - "type": "TYPE_INT32" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "order_by", - "type": "TYPE_STRING" - }, - { - "name": "histogram_queries", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "require_total_size", - "type": "TYPE_BOOL" - }, - { - "name": "qa_size_limit", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.SearchDocumentsResponse", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" - }, - "method": { - "shortName": "SearchDocuments", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.SearchDocuments", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentService_FetchAcl_async", - "title": "DocumentLinkService fetchAcl Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for a resource. Returns NOT_FOUND error if the resource does not exist. Returns an empty policy if the resource exists but does not have a policy set.", - "canonical": true, - "file": "document_service.fetch_acl.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "FetchAcl", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.FetchAcl", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - }, - { - "name": "project_owner", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.FetchAclResponse", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" - }, - "method": { - "shortName": "FetchAcl", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.FetchAcl", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_DocumentService_SetAcl_async", - "title": "DocumentLinkService setAcl Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy for a resource. Replaces any existing policy.", - "canonical": true, - "file": "document_service.set_acl.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetAcl", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.SetAcl", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "request_metadata", - "type": ".google.cloud.contentwarehouse.v1.RequestMetadata" - }, - { - "name": "project_owner", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.SetAclResponse", - "client": { - "shortName": "DocumentServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.DocumentServiceClient" - }, - "method": { - "shortName": "SetAcl", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService.SetAcl", - "service": { - "shortName": "DocumentService", - "fullName": "google.cloud.contentwarehouse.v1.DocumentService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_RuleSetService_CreateRuleSet_async", - "title": "DocumentLinkService createRuleSet Sample", - "origin": "API_DEFINITION", - "description": " Creates a ruleset.", - "canonical": true, - "file": "rule_set_service.create_rule_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateRuleSet", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.CreateRuleSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "rule_set", - "type": ".google.cloud.contentwarehouse.v1.RuleSet" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.RuleSet", - "client": { - "shortName": "RuleSetServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetServiceClient" - }, - "method": { - "shortName": "CreateRuleSet", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.CreateRuleSet", - "service": { - "shortName": "RuleSetService", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_RuleSetService_GetRuleSet_async", - "title": "DocumentLinkService getRuleSet Sample", - "origin": "API_DEFINITION", - "description": " Gets a ruleset. Returns NOT_FOUND if the ruleset does not exist.", - "canonical": true, - "file": "rule_set_service.get_rule_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetRuleSet", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.GetRuleSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.RuleSet", - "client": { - "shortName": "RuleSetServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetServiceClient" - }, - "method": { - "shortName": "GetRuleSet", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.GetRuleSet", - "service": { - "shortName": "RuleSetService", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_RuleSetService_UpdateRuleSet_async", - "title": "DocumentLinkService updateRuleSet Sample", - "origin": "API_DEFINITION", - "description": " Updates a ruleset. Returns INVALID_ARGUMENT if the name of the ruleset is non-empty and does not equal the existing name.", - "canonical": true, - "file": "rule_set_service.update_rule_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateRuleSet", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.UpdateRuleSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "rule_set", - "type": ".google.cloud.contentwarehouse.v1.RuleSet" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.RuleSet", - "client": { - "shortName": "RuleSetServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetServiceClient" - }, - "method": { - "shortName": "UpdateRuleSet", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.UpdateRuleSet", - "service": { - "shortName": "RuleSetService", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_RuleSetService_DeleteRuleSet_async", - "title": "DocumentLinkService deleteRuleSet Sample", - "origin": "API_DEFINITION", - "description": " Deletes a ruleset. Returns NOT_FOUND if the document does not exist.", - "canonical": true, - "file": "rule_set_service.delete_rule_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteRuleSet", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.DeleteRuleSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "RuleSetServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetServiceClient" - }, - "method": { - "shortName": "DeleteRuleSet", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.DeleteRuleSet", - "service": { - "shortName": "RuleSetService", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_RuleSetService_ListRuleSets_async", - "title": "DocumentLinkService listRuleSets Sample", - "origin": "API_DEFINITION", - "description": " Lists rulesets.", - "canonical": true, - "file": "rule_set_service.list_rule_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListRuleSets", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.ListRuleSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.ListRuleSetsResponse", - "client": { - "shortName": "RuleSetServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetServiceClient" - }, - "method": { - "shortName": "ListRuleSets", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService.ListRuleSets", - "service": { - "shortName": "RuleSetService", - "fullName": "google.cloud.contentwarehouse.v1.RuleSetService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_SynonymSetService_CreateSynonymSet_async", - "title": "DocumentLinkService createSynonymSet Sample", - "origin": "API_DEFINITION", - "description": " Creates a SynonymSet for a single context. Throws an ALREADY_EXISTS exception if a synonymset already exists for the context.", - "canonical": true, - "file": "synonym_set_service.create_synonym_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateSynonymSet", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.CreateSynonymSet", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "synonym_set", - "type": ".google.cloud.contentwarehouse.v1.SynonymSet" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.SynonymSet", - "client": { - "shortName": "SynonymSetServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetServiceClient" - }, - "method": { - "shortName": "CreateSynonymSet", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.CreateSynonymSet", - "service": { - "shortName": "SynonymSetService", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_SynonymSetService_GetSynonymSet_async", - "title": "DocumentLinkService getSynonymSet Sample", - "origin": "API_DEFINITION", - "description": " Gets a SynonymSet for a particular context. Throws a NOT_FOUND exception if the Synonymset does not exist", - "canonical": true, - "file": "synonym_set_service.get_synonym_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetSynonymSet", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.GetSynonymSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.SynonymSet", - "client": { - "shortName": "SynonymSetServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetServiceClient" - }, - "method": { - "shortName": "GetSynonymSet", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.GetSynonymSet", - "service": { - "shortName": "SynonymSetService", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_SynonymSetService_UpdateSynonymSet_async", - "title": "DocumentLinkService updateSynonymSet Sample", - "origin": "API_DEFINITION", - "description": " Remove the existing SynonymSet for the context and replaces it with a new one. Throws a NOT_FOUND exception if the SynonymSet is not found.", - "canonical": true, - "file": "synonym_set_service.update_synonym_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateSynonymSet", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.UpdateSynonymSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "synonym_set", - "type": ".google.cloud.contentwarehouse.v1.SynonymSet" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.SynonymSet", - "client": { - "shortName": "SynonymSetServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetServiceClient" - }, - "method": { - "shortName": "UpdateSynonymSet", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.UpdateSynonymSet", - "service": { - "shortName": "SynonymSetService", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_SynonymSetService_DeleteSynonymSet_async", - "title": "DocumentLinkService deleteSynonymSet Sample", - "origin": "API_DEFINITION", - "description": " Deletes a SynonymSet for a given context. Throws a NOT_FOUND exception if the SynonymSet is not found.", - "canonical": true, - "file": "synonym_set_service.delete_synonym_set.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteSynonymSet", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.DeleteSynonymSet", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "SynonymSetServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetServiceClient" - }, - "method": { - "shortName": "DeleteSynonymSet", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.DeleteSynonymSet", - "service": { - "shortName": "SynonymSetService", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService" - } - } - } - }, - { - "regionTag": "contentwarehouse_v1_generated_SynonymSetService_ListSynonymSets_async", - "title": "DocumentLinkService listSynonymSets Sample", - "origin": "API_DEFINITION", - "description": " Returns all SynonymSets (for all contexts) for the specified location.", - "canonical": true, - "file": "synonym_set_service.list_synonym_sets.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListSynonymSets", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.ListSynonymSets", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.contentwarehouse.v1.ListSynonymSetsResponse", - "client": { - "shortName": "SynonymSetServiceClient", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetServiceClient" - }, - "method": { - "shortName": "ListSynonymSets", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService.ListSynonymSets", - "service": { - "shortName": "SynonymSetService", - "fullName": "google.cloud.contentwarehouse.v1.SynonymSetService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.create_synonym_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.create_synonym_set.js deleted file mode 100644 index c6be0ae02c6..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.create_synonym_set.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, synonymSet) { - // [START contentwarehouse_v1_generated_SynonymSetService_CreateSynonymSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 name. - * Format: projects/{project_number}/locations/{location}. - */ - // const parent = 'abc123' - /** - * Required. The synonymSet to be created for a context - */ - // const synonymSet = {} - - // Imports the Contentwarehouse library - const {SynonymSetServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new SynonymSetServiceClient(); - - async function callCreateSynonymSet() { - // Construct request - const request = { - parent, - synonymSet, - }; - - // Run request - const response = await contentwarehouseClient.createSynonymSet(request); - console.log(response); - } - - callCreateSynonymSet(); - // [END contentwarehouse_v1_generated_SynonymSetService_CreateSynonymSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.delete_synonym_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.delete_synonym_set.js deleted file mode 100644 index 82a7bb6f94e..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.delete_synonym_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START contentwarehouse_v1_generated_SynonymSetService_DeleteSynonymSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 synonymSet to delete - * Format: - * projects/{project_number}/locations/{location}/synonymSets/{context}. - */ - // const name = 'abc123' - - // Imports the Contentwarehouse library - const {SynonymSetServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new SynonymSetServiceClient(); - - async function callDeleteSynonymSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await contentwarehouseClient.deleteSynonymSet(request); - console.log(response); - } - - callDeleteSynonymSet(); - // [END contentwarehouse_v1_generated_SynonymSetService_DeleteSynonymSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.get_synonym_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.get_synonym_set.js deleted file mode 100644 index 9f3367f25fe..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.get_synonym_set.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START contentwarehouse_v1_generated_SynonymSetService_GetSynonymSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 synonymSet to retrieve - * Format: - * projects/{project_number}/locations/{location}/synonymSets/{context}. - */ - // const name = 'abc123' - - // Imports the Contentwarehouse library - const {SynonymSetServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new SynonymSetServiceClient(); - - async function callGetSynonymSet() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await contentwarehouseClient.getSynonymSet(request); - console.log(response); - } - - callGetSynonymSet(); - // [END contentwarehouse_v1_generated_SynonymSetService_GetSynonymSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.list_synonym_sets.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.list_synonym_sets.js deleted file mode 100644 index 0f9fff5df07..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.list_synonym_sets.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START contentwarehouse_v1_generated_SynonymSetService_ListSynonymSets_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 name. - * Format: projects/{project_number}/locations/{location}. - */ - // const parent = 'abc123' - /** - * The maximum number of synonymSets to return. The service may return - * fewer than this value. - * If unspecified, at most 50 rule sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - */ - // const pageSize = 1234 - /** - * A page token, received from a previous `ListSynonymSets` call. - * Provide this to retrieve the subsequent page. - * When paginating, all other parameters provided to `ListSynonymSets` - * must match the call that provided the page token. - */ - // const pageToken = 'abc123' - - // Imports the Contentwarehouse library - const {SynonymSetServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new SynonymSetServiceClient(); - - async function callListSynonymSets() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await contentwarehouseClient.listSynonymSetsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListSynonymSets(); - // [END contentwarehouse_v1_generated_SynonymSetService_ListSynonymSets_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.update_synonym_set.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.update_synonym_set.js deleted file mode 100644 index 6df8717dcf7..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/samples/generated/v1/synonym_set_service.update_synonym_set.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, synonymSet) { - // [START contentwarehouse_v1_generated_SynonymSetService_UpdateSynonymSet_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will 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 synonymSet to update - * Format: - * projects/{project_number}/locations/{location}/synonymSets/{context}. - */ - // const name = 'abc123' - /** - * Required. The synonymSet to be updated for the customer - */ - // const synonymSet = {} - - // Imports the Contentwarehouse library - const {SynonymSetServiceClient} = require('@google-cloud/contentwarehouse').v1; - - // Instantiates a client - const contentwarehouseClient = new SynonymSetServiceClient(); - - async function callUpdateSynonymSet() { - // Construct request - const request = { - name, - synonymSet, - }; - - // Run request - const response = await contentwarehouseClient.updateSynonymSet(request); - console.log(response); - } - - callUpdateSynonymSet(); - // [END contentwarehouse_v1_generated_SynonymSetService_UpdateSynonymSet_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/index.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/index.ts deleted file mode 100644 index 6bba2b51edc..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const DocumentLinkServiceClient = v1.DocumentLinkServiceClient; -type DocumentLinkServiceClient = v1.DocumentLinkServiceClient; -const DocumentSchemaServiceClient = v1.DocumentSchemaServiceClient; -type DocumentSchemaServiceClient = v1.DocumentSchemaServiceClient; -const DocumentServiceClient = v1.DocumentServiceClient; -type DocumentServiceClient = v1.DocumentServiceClient; -const RuleSetServiceClient = v1.RuleSetServiceClient; -type RuleSetServiceClient = v1.RuleSetServiceClient; -const SynonymSetServiceClient = v1.SynonymSetServiceClient; -type SynonymSetServiceClient = v1.SynonymSetServiceClient; -export {v1, DocumentLinkServiceClient, DocumentSchemaServiceClient, DocumentServiceClient, RuleSetServiceClient, SynonymSetServiceClient}; -export default {v1, DocumentLinkServiceClient, DocumentSchemaServiceClient, DocumentServiceClient, RuleSetServiceClient, SynonymSetServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client.ts deleted file mode 100644 index 035693b0614..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client.ts +++ /dev/null @@ -1,1095 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/document_link_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './document_link_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * This service lets you manage document-links. - * Document-Links are treated as sub-resources under source documents. - * @class - * @memberof v1 - */ -export class DocumentLinkServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - documentLinkServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DocumentLinkServiceClient. - * - * @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 DocumentLinkServiceClient({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 DocumentLinkServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - documentLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}' - ), - documentSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documentSchemas/{document_schema}' - ), - projectLocationDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/{document}' - ), - projectLocationDocumentsReferenceIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/referenceId/{reference_id}' - ), - ruleSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ruleSets/{rule_set}' - ), - synonymSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/synonymSets/{context}' - ), - }; - - // 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 = { - listLinkedSources: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documentLinks') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.contentwarehouse.v1.DocumentLinkService', 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.documentLinkServiceStub) { - return this.documentLinkServiceStub; - } - - // Put together the "service stub" for - // google.cloud.contentwarehouse.v1.DocumentLinkService. - this.documentLinkServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.contentwarehouse.v1.DocumentLinkService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.contentwarehouse.v1.DocumentLinkService, - 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 documentLinkServiceStubMethods = - ['listLinkedTargets', 'listLinkedSources', 'createDocumentLink', 'deleteDocumentLink']; - for (const methodName of documentLinkServiceStubMethods) { - const callPromise = this.documentLinkServiceStub.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.documentLinkServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'contentwarehouse.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 'contentwarehouse.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 -- - // ------------------- -/** - * Return all target document-links from the document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the document, for which all target links are returned. - * Format: - * projects/{project_number}/locations/{location}/documents/{target_document_id}. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the document creator, used to enforce - * access control for the service. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ListLinkedTargetsResponse]{@link google.cloud.contentwarehouse.v1.ListLinkedTargetsResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_link_service.list_linked_targets.js - * region_tag:contentwarehouse_v1_generated_DocumentLinkService_ListLinkedTargets_async - */ - listLinkedTargets( - request?: protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|undefined, {}|undefined - ]>; - listLinkedTargets( - request: protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|null|undefined, - {}|null|undefined>): void; - listLinkedTargets( - request: protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|null|undefined, - {}|null|undefined>): void; - listLinkedTargets( - request?: protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse, - protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listLinkedTargets(request, options, callback); - } -/** - * Create a link between a source document and a target document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent of the document-link to be created. - * parent of document-link should be a document. - * Format: - * projects/{project_number}/locations/{location}/documents/{source_document_id}. - * @param {google.cloud.contentwarehouse.v1.DocumentLink} request.documentLink - * Required. Document links associated with the source documents (source_document_id). - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the document creator, used to enforce - * access control for the service. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [DocumentLink]{@link google.cloud.contentwarehouse.v1.DocumentLink}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_link_service.create_document_link.js - * region_tag:contentwarehouse_v1_generated_DocumentLinkService_CreateDocumentLink_async - */ - createDocumentLink( - request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentLink, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|undefined, {}|undefined - ]>; - createDocumentLink( - request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentLink, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|null|undefined, - {}|null|undefined>): void; - createDocumentLink( - request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentLink, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|null|undefined, - {}|null|undefined>): void; - createDocumentLink( - request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentLink, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentLink, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentLink, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentLinkRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createDocumentLink(request, options, callback); - } -/** - * Remove the link between the source and target documents. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the document-link to be deleted. - * Format: - * projects/{project_number}/locations/{location}/documents/{source_document_id}/documentLinks/{document_link_id}. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the document creator, used to enforce - * access control for the service. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_link_service.delete_document_link.js - * region_tag:contentwarehouse_v1_generated_DocumentLinkService_DeleteDocumentLink_async - */ - deleteDocumentLink( - request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|undefined, {}|undefined - ]>; - deleteDocumentLink( - request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|null|undefined, - {}|null|undefined>): void; - deleteDocumentLink( - request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|null|undefined, - {}|null|undefined>): void; - deleteDocumentLink( - request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentLinkRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteDocumentLink(request, options, callback); - } - - /** - * Return all source document-links from the document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the document, for which all source links are returned. - * Format: - * projects/{project_number}/locations/{location}/documents/{source_document_id}. - * @param {number} request.pageSize - * The maximum number of document-links to return. The service may return - * fewer than this value. - * - * If unspecified, at most 50 document-links will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListLinkedSources` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListLinkedSources` - * must match the call that provided the page token. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the document creator, used to enforce - * access control for the service. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [DocumentLink]{@link google.cloud.contentwarehouse.v1.DocumentLink}. - * 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 `listLinkedSourcesAsync()` - * 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. - */ - listLinkedSources( - request?: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentLink[], - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest|null, - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse - ]>; - listLinkedSources( - request: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IDocumentLink>): void; - listLinkedSources( - request: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, - callback: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IDocumentLink>): void; - listLinkedSources( - request?: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IDocumentLink>, - callback?: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IDocumentLink>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentLink[], - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest|null, - protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listLinkedSources(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 name of the document, for which all source links are returned. - * Format: - * projects/{project_number}/locations/{location}/documents/{source_document_id}. - * @param {number} request.pageSize - * The maximum number of document-links to return. The service may return - * fewer than this value. - * - * If unspecified, at most 50 document-links will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListLinkedSources` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListLinkedSources` - * must match the call that provided the page token. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the document creator, used to enforce - * access control for the service. - * @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 [DocumentLink]{@link google.cloud.contentwarehouse.v1.DocumentLink} 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 `listLinkedSourcesAsync()` - * 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. - */ - listLinkedSourcesStream( - request?: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, - 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['listLinkedSources']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listLinkedSources.createStream( - this.innerApiCalls.listLinkedSources as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listLinkedSources`, 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 name of the document, for which all source links are returned. - * Format: - * projects/{project_number}/locations/{location}/documents/{source_document_id}. - * @param {number} request.pageSize - * The maximum number of document-links to return. The service may return - * fewer than this value. - * - * If unspecified, at most 50 document-links will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListLinkedSources` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListLinkedSources` - * must match the call that provided the page token. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the document creator, used to enforce - * access control for the service. - * @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 - * [DocumentLink]{@link google.cloud.contentwarehouse.v1.DocumentLink}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/document_link_service.list_linked_sources.js - * region_tag:contentwarehouse_v1_generated_DocumentLinkService_ListLinkedSources_async - */ - listLinkedSourcesAsync( - request?: protos.google.cloud.contentwarehouse.v1.IListLinkedSourcesRequest, - 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['listLinkedSources']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listLinkedSources.asyncIterate( - this.innerApiCalls['listLinkedSources'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified documentLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document - * @param {string} document_link - * @returns {string} Resource name string. - */ - documentLinkPath(project:string,location:string,document:string,documentLink:string) { - return this.pathTemplates.documentLinkPathTemplate.render({ - project: project, - location: location, - document: document, - document_link: documentLink, - }); - } - - /** - * Parse the project from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).project; - } - - /** - * Parse the location from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).location; - } - - /** - * Parse the document from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document; - } - - /** - * Parse the document_link from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the document_link. - */ - matchDocumentLinkFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document_link; - } - - /** - * Return a fully-qualified documentSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document_schema - * @returns {string} Resource name string. - */ - documentSchemaPath(project:string,location:string,documentSchema:string) { - return this.pathTemplates.documentSchemaPathTemplate.render({ - project: project, - location: location, - document_schema: documentSchema, - }); - } - - /** - * Parse the project from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).project; - } - - /** - * Parse the location from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).location; - } - - /** - * Parse the document_schema from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the document_schema. - */ - matchDocumentSchemaFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).document_schema; - } - - /** - * Return a fully-qualified projectLocationDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDocumentPath(project:string,location:string,document:string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.render({ - project: project, - location: location, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).location; - } - - /** - * Parse the document from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDocumentsReferenceId resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} reference_id - * @returns {string} Resource name string. - */ - projectLocationDocumentsReferenceIdPath(project:string,location:string,referenceId:string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render({ - project: project, - location: location, - reference_id: referenceId, - }); - } - - /** - * Parse the project from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).project; - } - - /** - * Parse the location from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).location; - } - - /** - * Parse the reference_id from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the reference_id. - */ - matchReferenceIdFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).reference_id; - } - - /** - * Return a fully-qualified ruleSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} rule_set - * @returns {string} Resource name string. - */ - ruleSetPath(project:string,location:string,ruleSet:string) { - return this.pathTemplates.ruleSetPathTemplate.render({ - project: project, - location: location, - rule_set: ruleSet, - }); - } - - /** - * Parse the project from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).project; - } - - /** - * Parse the location from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).location; - } - - /** - * Parse the rule_set from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the rule_set. - */ - matchRuleSetFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).rule_set; - } - - /** - * Return a fully-qualified synonymSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} context - * @returns {string} Resource name string. - */ - synonymSetPath(project:string,location:string,context:string) { - return this.pathTemplates.synonymSetPathTemplate.render({ - project: project, - location: location, - context: context, - }); - } - - /** - * Parse the project from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).project; - } - - /** - * Parse the location from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).location; - } - - /** - * Parse the context from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the context. - */ - matchContextFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).context; - } - - /** - * 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.documentLinkServiceStub && !this._terminated) { - return this.documentLinkServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client_config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client_config.json deleted file mode 100644 index 50fc7af4f4a..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.contentwarehouse.v1.DocumentLinkService": { - "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": { - "ListLinkedTargets": { - "timeout_millis": 180000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListLinkedSources": { - "timeout_millis": 180000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateDocumentLink": { - "timeout_millis": 180000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteDocumentLink": { - "timeout_millis": 180000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_proto_list.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_proto_list.json deleted file mode 100644 index e85ca71c0c6..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_link_service_proto_list.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - "../../protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/common.proto", - "../../protos/google/cloud/contentwarehouse/v1/document.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_link_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_schema.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_schema_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/filters.proto", - "../../protos/google/cloud/contentwarehouse/v1/histogram.proto", - "../../protos/google/cloud/contentwarehouse/v1/rule_engine.proto", - "../../protos/google/cloud/contentwarehouse/v1/ruleset_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto", - "../../protos/google/cloud/documentai/v1/barcode.proto", - "../../protos/google/cloud/documentai/v1/document.proto", - "../../protos/google/cloud/documentai/v1/geometry.proto" -] diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client.ts deleted file mode 100644 index 80264b81bea..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client.ts +++ /dev/null @@ -1,1185 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/document_schema_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './document_schema_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * This service lets you manage document schema. - * @class - * @memberof v1 - */ -export class DocumentSchemaServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - documentSchemaServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DocumentSchemaServiceClient. - * - * @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 DocumentSchemaServiceClient({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 DocumentSchemaServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - documentLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}' - ), - documentSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documentSchemas/{document_schema}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - projectLocationDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/{document}' - ), - projectLocationDocumentsReferenceIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/referenceId/{reference_id}' - ), - ruleSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ruleSets/{rule_set}' - ), - synonymSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/synonymSets/{context}' - ), - }; - - // 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 = { - listDocumentSchemas: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documentSchemas') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.contentwarehouse.v1.DocumentSchemaService', 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.documentSchemaServiceStub) { - return this.documentSchemaServiceStub; - } - - // Put together the "service stub" for - // google.cloud.contentwarehouse.v1.DocumentSchemaService. - this.documentSchemaServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.contentwarehouse.v1.DocumentSchemaService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.contentwarehouse.v1.DocumentSchemaService, - 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 documentSchemaServiceStubMethods = - ['createDocumentSchema', 'updateDocumentSchema', 'getDocumentSchema', 'deleteDocumentSchema', 'listDocumentSchemas']; - for (const methodName of documentSchemaServiceStubMethods) { - const callPromise = this.documentSchemaServiceStub.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.documentSchemaServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'contentwarehouse.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 'contentwarehouse.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 document schema. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent name. - * @param {google.cloud.contentwarehouse.v1.DocumentSchema} request.documentSchema - * Required. The document schema to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_schema_service.create_document_schema.js - * region_tag:contentwarehouse_v1_generated_DocumentSchemaService_CreateDocumentSchema_async - */ - createDocumentSchema( - request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|undefined, {}|undefined - ]>; - createDocumentSchema( - request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|null|undefined, - {}|null|undefined>): void; - createDocumentSchema( - request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|null|undefined, - {}|null|undefined>): void; - createDocumentSchema( - request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentSchemaRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createDocumentSchema(request, options, callback); - } -/** - * Updates a Document Schema. Returns INVALID_ARGUMENT if the name of the - * Document Schema is non-empty and does not equal the existing name. - * Supports only appending new properties, adding new ENUM possible values, - * and updating the {@link google.cloud.contentwarehouse.v1.EnumTypeOptions.validation_check_disabled|EnumTypeOptions.validation_check_disabled} flag for - * ENUM possible values. Updating existing properties will result into - * INVALID_ARGUMENT. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the document schema to update. - * Format: - * projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}. - * @param {google.cloud.contentwarehouse.v1.DocumentSchema} request.documentSchema - * Required. The document schema to update with. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_schema_service.update_document_schema.js - * region_tag:contentwarehouse_v1_generated_DocumentSchemaService_UpdateDocumentSchema_async - */ - updateDocumentSchema( - request?: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|undefined, {}|undefined - ]>; - updateDocumentSchema( - request: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|null|undefined, - {}|null|undefined>): void; - updateDocumentSchema( - request: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|null|undefined, - {}|null|undefined>): void; - updateDocumentSchema( - request?: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentSchemaRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.updateDocumentSchema(request, options, callback); - } -/** - * Gets a document schema. Returns NOT_FOUND if the document schema does not - * exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the document schema to retrieve. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_schema_service.get_document_schema.js - * region_tag:contentwarehouse_v1_generated_DocumentSchemaService_GetDocumentSchema_async - */ - getDocumentSchema( - request?: protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|undefined, {}|undefined - ]>; - getDocumentSchema( - request: protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|null|undefined, - {}|null|undefined>): void; - getDocumentSchema( - request: protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|null|undefined, - {}|null|undefined>): void; - getDocumentSchema( - request?: protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentSchema, - protos.google.cloud.contentwarehouse.v1.IGetDocumentSchemaRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getDocumentSchema(request, options, callback); - } -/** - * Deletes a document schema. Returns NOT_FOUND if the document schema does - * not exist. Returns BAD_REQUEST if the document schema has documents - * depending on it. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the document schema to delete. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_schema_service.delete_document_schema.js - * region_tag:contentwarehouse_v1_generated_DocumentSchemaService_DeleteDocumentSchema_async - */ - deleteDocumentSchema( - request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|undefined, {}|undefined - ]>; - deleteDocumentSchema( - request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|null|undefined, - {}|null|undefined>): void; - deleteDocumentSchema( - request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|null|undefined, - {}|null|undefined>): void; - deleteDocumentSchema( - request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentSchemaRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteDocumentSchema(request, options, callback); - } - - /** - * Lists document schemas. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of document schemas. - * Format: projects/{project_number}/locations/{location}. - * @param {number} request.pageSize - * The maximum number of document schemas to return. The service may return - * fewer than this value. - * If unspecified, at most 50 document schemas will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListDocumentSchemas` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListDocumentSchemas` - * must match the call that provided the page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema}. - * 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 `listDocumentSchemasAsync()` - * 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. - */ - listDocumentSchemas( - request?: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentSchema[], - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest|null, - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse - ]>; - listDocumentSchemas( - request: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IDocumentSchema>): void; - listDocumentSchemas( - request: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, - callback: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IDocumentSchema>): void; - listDocumentSchemas( - request?: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IDocumentSchema>, - callback?: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IDocumentSchema>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocumentSchema[], - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest|null, - protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listDocumentSchemas(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, which owns this collection of document schemas. - * Format: projects/{project_number}/locations/{location}. - * @param {number} request.pageSize - * The maximum number of document schemas to return. The service may return - * fewer than this value. - * If unspecified, at most 50 document schemas will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListDocumentSchemas` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListDocumentSchemas` - * must match the call that provided the page token. - * @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 [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema} 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 `listDocumentSchemasAsync()` - * 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. - */ - listDocumentSchemasStream( - request?: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, - 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['listDocumentSchemas']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocumentSchemas.createStream( - this.innerApiCalls.listDocumentSchemas as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listDocumentSchemas`, 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, which owns this collection of document schemas. - * Format: projects/{project_number}/locations/{location}. - * @param {number} request.pageSize - * The maximum number of document schemas to return. The service may return - * fewer than this value. - * If unspecified, at most 50 document schemas will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListDocumentSchemas` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListDocumentSchemas` - * must match the call that provided the 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 - * [DocumentSchema]{@link google.cloud.contentwarehouse.v1.DocumentSchema}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/document_schema_service.list_document_schemas.js - * region_tag:contentwarehouse_v1_generated_DocumentSchemaService_ListDocumentSchemas_async - */ - listDocumentSchemasAsync( - request?: protos.google.cloud.contentwarehouse.v1.IListDocumentSchemasRequest, - 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['listDocumentSchemas']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDocumentSchemas.asyncIterate( - this.innerApiCalls['listDocumentSchemas'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified documentLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document - * @param {string} document_link - * @returns {string} Resource name string. - */ - documentLinkPath(project:string,location:string,document:string,documentLink:string) { - return this.pathTemplates.documentLinkPathTemplate.render({ - project: project, - location: location, - document: document, - document_link: documentLink, - }); - } - - /** - * Parse the project from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).project; - } - - /** - * Parse the location from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).location; - } - - /** - * Parse the document from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document; - } - - /** - * Parse the document_link from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the document_link. - */ - matchDocumentLinkFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document_link; - } - - /** - * Return a fully-qualified documentSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document_schema - * @returns {string} Resource name string. - */ - documentSchemaPath(project:string,location:string,documentSchema:string) { - return this.pathTemplates.documentSchemaPathTemplate.render({ - project: project, - location: location, - document_schema: documentSchema, - }); - } - - /** - * Parse the project from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).project; - } - - /** - * Parse the location from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).location; - } - - /** - * Parse the document_schema from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the document_schema. - */ - matchDocumentSchemaFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).document_schema; - } - - /** - * 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 projectLocationDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDocumentPath(project:string,location:string,document:string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.render({ - project: project, - location: location, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).location; - } - - /** - * Parse the document from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDocumentsReferenceId resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} reference_id - * @returns {string} Resource name string. - */ - projectLocationDocumentsReferenceIdPath(project:string,location:string,referenceId:string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render({ - project: project, - location: location, - reference_id: referenceId, - }); - } - - /** - * Parse the project from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).project; - } - - /** - * Parse the location from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).location; - } - - /** - * Parse the reference_id from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the reference_id. - */ - matchReferenceIdFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).reference_id; - } - - /** - * Return a fully-qualified ruleSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} rule_set - * @returns {string} Resource name string. - */ - ruleSetPath(project:string,location:string,ruleSet:string) { - return this.pathTemplates.ruleSetPathTemplate.render({ - project: project, - location: location, - rule_set: ruleSet, - }); - } - - /** - * Parse the project from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).project; - } - - /** - * Parse the location from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).location; - } - - /** - * Parse the rule_set from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the rule_set. - */ - matchRuleSetFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).rule_set; - } - - /** - * Return a fully-qualified synonymSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} context - * @returns {string} Resource name string. - */ - synonymSetPath(project:string,location:string,context:string) { - return this.pathTemplates.synonymSetPathTemplate.render({ - project: project, - location: location, - context: context, - }); - } - - /** - * Parse the project from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).project; - } - - /** - * Parse the location from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).location; - } - - /** - * Parse the context from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the context. - */ - matchContextFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).context; - } - - /** - * 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.documentSchemaServiceStub && !this._terminated) { - return this.documentSchemaServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client_config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client_config.json deleted file mode 100644 index 80dfa82b9d0..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_client_config.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "interfaces": { - "google.cloud.contentwarehouse.v1.DocumentSchemaService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateDocumentSchema": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateDocumentSchema": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetDocumentSchema": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "DeleteDocumentSchema": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListDocumentSchemas": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_proto_list.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_proto_list.json deleted file mode 100644 index e85ca71c0c6..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_schema_service_proto_list.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - "../../protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/common.proto", - "../../protos/google/cloud/contentwarehouse/v1/document.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_link_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_schema.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_schema_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/filters.proto", - "../../protos/google/cloud/contentwarehouse/v1/histogram.proto", - "../../protos/google/cloud/contentwarehouse/v1/rule_engine.proto", - "../../protos/google/cloud/contentwarehouse/v1/ruleset_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto", - "../../protos/google/cloud/documentai/v1/barcode.proto", - "../../protos/google/cloud/documentai/v1/document.proto", - "../../protos/google/cloud/documentai/v1/geometry.proto" -] diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client.ts deleted file mode 100644 index bc617cbeebf..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client.ts +++ /dev/null @@ -1,1557 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/document_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './document_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * This service lets you manage document. - * @class - * @memberof v1 - */ -export class DocumentServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - documentServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DocumentServiceClient. - * - * @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 DocumentServiceClient({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 DocumentServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - documentLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}' - ), - documentSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documentSchemas/{document_schema}' - ), - projectLocationDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/{document}' - ), - projectLocationDocumentsReferenceIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/referenceId/{reference_id}' - ), - ruleSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ruleSets/{rule_set}' - ), - synonymSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/synonymSets/{context}' - ), - }; - - // 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 = { - searchDocuments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'matchingDocuments') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.contentwarehouse.v1.DocumentService', 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.documentServiceStub) { - return this.documentServiceStub; - } - - // Put together the "service stub" for - // google.cloud.contentwarehouse.v1.DocumentService. - this.documentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.contentwarehouse.v1.DocumentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.contentwarehouse.v1.DocumentService, - 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 documentServiceStubMethods = - ['createDocument', 'getDocument', 'updateDocument', 'deleteDocument', 'searchDocuments', 'fetchAcl', 'setAcl']; - for (const methodName of documentServiceStubMethods) { - const callPromise = this.documentServiceStub.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.documentServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'contentwarehouse.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 'contentwarehouse.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 document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent name. - * Format: projects/{project_number}/locations/{location}. - * @param {google.cloud.contentwarehouse.v1.Document} request.document - * Required. The document to create. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the end user, used to enforce access - * control for the service. - * @param {google.iam.v1.Policy} request.policy - * Default document policy during creation. Conditions defined in the policy - * will be ignored. - * @param {google.cloud.contentwarehouse.v1.CloudAIDocumentOption} request.cloudAiDocumentOption - * Request Option for processing Cloud AI Document in CW Document. - * @param {google.protobuf.FieldMask} request.createMask - * Field mask for creating Document fields. If mask path is empty, - * it means all fields are masked. - * For the `FieldMask` definition, - * see - * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CreateDocumentResponse]{@link google.cloud.contentwarehouse.v1.CreateDocumentResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_service.create_document.js - * region_tag:contentwarehouse_v1_generated_DocumentService_CreateDocument_async - */ - createDocument( - request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|undefined, {}|undefined - ]>; - createDocument( - request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): void; - createDocument( - request: protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): void; - createDocument( - request?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.ICreateDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createDocument(request, options, callback); - } -/** - * Gets a document. Returns NOT_FOUND if the document does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the document to retrieve. - * Format: - * projects/{project_number}/locations/{location}/documents/{document_id} or - * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the end user, used to enforce access - * control for the service. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Document]{@link google.cloud.contentwarehouse.v1.Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_service.get_document.js - * region_tag:contentwarehouse_v1_generated_DocumentService_GetDocument_async - */ - getDocument( - request?: protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocument, - protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|undefined, {}|undefined - ]>; - getDocument( - request: protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IDocument, - protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): void; - getDocument( - request: protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IDocument, - protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): void; - getDocument( - request?: protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IDocument, - protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IDocument, - protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IDocument, - protos.google.cloud.contentwarehouse.v1.IGetDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getDocument(request, options, callback); - } -/** - * Updates a document. Returns INVALID_ARGUMENT if the name of the document - * is non-empty and does not equal the existing name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the document to update. - * Format: - * projects/{project_number}/locations/{location}/documents/{document_id} - * or - * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. - * @param {google.cloud.contentwarehouse.v1.Document} request.document - * Required. The document to update. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the end user, used to enforce access - * control for the service. - * @param {google.cloud.contentwarehouse.v1.CloudAIDocumentOption} request.cloudAiDocumentOption - * Request Option for processing Cloud AI Document in CW Document. - * @param {google.cloud.contentwarehouse.v1.UpdateOptions} request.updateOptions - * Options for the update operation. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [UpdateDocumentResponse]{@link google.cloud.contentwarehouse.v1.UpdateDocumentResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_service.update_document.js - * region_tag:contentwarehouse_v1_generated_DocumentService_UpdateDocument_async - */ - updateDocument( - request?: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|undefined, {}|undefined - ]>; - updateDocument( - request: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): void; - updateDocument( - request: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): void; - updateDocument( - request?: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse, - protos.google.cloud.contentwarehouse.v1.IUpdateDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateDocument(request, options, callback); - } -/** - * Deletes a document. Returns NOT_FOUND if the document does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the document to delete. - * Format: - * projects/{project_number}/locations/{location}/documents/{document_id} - * or - * projects/{project_number}/locations/{location}/documents/referenceId/{reference_id}. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the end user, used to enforce access - * control for the service. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_service.delete_document.js - * region_tag:contentwarehouse_v1_generated_DocumentService_DeleteDocument_async - */ - deleteDocument( - request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|undefined, {}|undefined - ]>; - deleteDocument( - request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): void; - deleteDocument( - request: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): void; - deleteDocument( - request?: protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteDocument(request, options, callback); - } -/** - * Gets the access control policy for a resource. Returns NOT_FOUND error if - * the resource does not exist. Returns an empty policy if the resource exists - * but does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * Required. REQUIRED: The resource for which the policy is being requested. - * Format for document: - * projects/{project_number}/locations/{location}/documents/{document_id}. - * Format for project: projects/{project_number}. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the end user, used to enforce access - * control for the service. - * @param {boolean} request.projectOwner - * For Get Project ACL only. Authorization check for end user will be ignored - * when project_owner=true. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [FetchAclResponse]{@link google.cloud.contentwarehouse.v1.FetchAclResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_service.fetch_acl.js - * region_tag:contentwarehouse_v1_generated_DocumentService_FetchAcl_async - */ - fetchAcl( - request?: protos.google.cloud.contentwarehouse.v1.IFetchAclRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, - protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|undefined, {}|undefined - ]>; - fetchAcl( - request: protos.google.cloud.contentwarehouse.v1.IFetchAclRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, - protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|null|undefined, - {}|null|undefined>): void; - fetchAcl( - request: protos.google.cloud.contentwarehouse.v1.IFetchAclRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, - protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|null|undefined, - {}|null|undefined>): void; - fetchAcl( - request?: protos.google.cloud.contentwarehouse.v1.IFetchAclRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, - protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, - protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IFetchAclResponse, - protos.google.cloud.contentwarehouse.v1.IFetchAclRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.fetchAcl(request, options, callback); - } -/** - * Sets the access control policy for a resource. Replaces any existing - * policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * Required. REQUIRED: The resource for which the policy is being requested. - * Format for document: - * projects/{project_number}/locations/{location}/documents/{document_id}. - * Format for project: projects/{project_number}. - * @param {google.iam.v1.Policy} request.policy - * Required. REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the end user, used to enforce access - * control for the service. - * @param {boolean} request.projectOwner - * For Set Project ACL only. Authorization check for end user will be ignored - * when project_owner=true. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [SetAclResponse]{@link google.cloud.contentwarehouse.v1.SetAclResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_service.set_acl.js - * region_tag:contentwarehouse_v1_generated_DocumentService_SetAcl_async - */ - setAcl( - request?: protos.google.cloud.contentwarehouse.v1.ISetAclRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ISetAclResponse, - protos.google.cloud.contentwarehouse.v1.ISetAclRequest|undefined, {}|undefined - ]>; - setAcl( - request: protos.google.cloud.contentwarehouse.v1.ISetAclRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.ISetAclResponse, - protos.google.cloud.contentwarehouse.v1.ISetAclRequest|null|undefined, - {}|null|undefined>): void; - setAcl( - request: protos.google.cloud.contentwarehouse.v1.ISetAclRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.ISetAclResponse, - protos.google.cloud.contentwarehouse.v1.ISetAclRequest|null|undefined, - {}|null|undefined>): void; - setAcl( - request?: protos.google.cloud.contentwarehouse.v1.ISetAclRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.ISetAclResponse, - protos.google.cloud.contentwarehouse.v1.ISetAclRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.ISetAclResponse, - protos.google.cloud.contentwarehouse.v1.ISetAclRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ISetAclResponse, - protos.google.cloud.contentwarehouse.v1.ISetAclRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'resource': request.resource ?? '', - }); - this.initialize(); - return this.innerApiCalls.setAcl(request, options, callback); - } - - /** - * Searches for documents using provided {@link google.cloud.contentwarehouse.v1.SearchDocumentsRequest|SearchDocumentsRequest}. - * This call only returns documents that the caller has permission to search - * against. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of documents. - * Format: projects/{project_number}/locations/{location}. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the end user, used to enforce access - * control and improve the search quality of the service. - * @param {google.cloud.contentwarehouse.v1.DocumentQuery} request.documentQuery - * Query used to search against documents (keyword, filters, etc.). - * @param {number} request.offset - * An integer that specifies the current offset (that is, starting result - * location, amongst the documents deemed by the API as relevant) in search - * results. This field is only considered if {@link google.cloud.contentwarehouse.v1.SearchDocumentsRequest.page_token|page_token} is unset. - * - * The maximum allowed value is 5000. Otherwise an error is thrown. - * - * For example, 0 means to return results starting from the first matching - * document, and 10 means to return from the 11th document. This can be used - * for pagination, (for example, pageSize = 10 and offset = 10 means to return - * from the second page). - * @param {number} request.pageSize - * A limit on the number of documents returned in the search results. - * Increasing this value above the default value of 10 can increase search - * response time. The value can be between 1 and 100. - * @param {string} request.pageToken - * The token specifying the current offset within search results. - * See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.next_page_token|SearchDocumentsResponse.next_page_token} for an explanation of how - * to obtain the next set of query results. - * @param {string} request.orderBy - * The criteria determining how search results are sorted. For non-empty - * query, default is `"relevance desc"`. For empty query, default is - * `"upload_date desc"`. - * - * Supported options are: - * - * * `"relevance desc"`: By relevance descending, as determined by the API - * algorithms. - * * `"upload_date desc"`: By upload date descending. - * * `"upload_date"`: By upload date ascending. - * * `"update_date desc"`: By last updated date descending. - * * `"update_date"`: By last updated date ascending. - * @param {number[]} request.histogramQueries - * An expression specifying a histogram request against matching - * documents. Expression syntax is an aggregation function call with - * histogram facets and other options. - * - * The following aggregation functions are supported: - * - * * `count(string_histogram_facet)`: Count the number of matching entities - * for each distinct attribute value. - * - * Data types: - * - * * Histogram facet (aka filterable properties): Facet names with format - * <schema id>.<facet>. Facets will have the - * format of: `{@link a-zA-Z0-9_:/-.|a-zA-Z}`. If the facet is a child - * facet, then the parent hierarchy needs to be specified separated by - * dots in the prefix after the schema id. Thus, the format for a multi- - * level facet is: <schema id>.<parent facet name>. - * <child facet name>. Example: - * schema123.root_parent_facet.middle_facet.child_facet - * * DocumentSchemaId: (with no schema id prefix) to get - * histograms for each document type (returns the schema id path, e.g. - * projects/12345/locations/us-west/documentSchemas/abc123). - * - * Example expression: - * - * * Document type counts: - * count('DocumentSchemaId') - * - * * For schema id, abc123, get the counts for MORTGAGE_TYPE: - * count('abc123.MORTGAGE_TYPE') - * @param {boolean} request.requireTotalSize - * Optional. Controls if the search document request requires the return of a total size - * of matched documents. See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.total_size|SearchDocumentsResponse.total_size}. - * - * Enabling this flag may adversely impact performance. Hint: If this is - * used with pagination, set this flag on the initial query but set this - * to false on subsequent page calls (keep the total count locally). - * - * Defaults to false. - * @param {number} request.qaSizeLimit - * Experimental, do not use. - * The limit on the number of documents returned for the question-answering - * feature. To enable the question-answering feature, set - * {@link |DocumentQuery].[is_nl_query} to true. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [MatchingDocument]{@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument}. - * 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 `searchDocumentsAsync()` - * 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. - */ - searchDocuments( - request?: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument[], - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest|null, - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse - ]>; - searchDocuments( - request: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument>): void; - searchDocuments( - request: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, - callback: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument>): void; - searchDocuments( - request?: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument>, - callback?: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument[], - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest|null, - protos.google.cloud.contentwarehouse.v1.ISearchDocumentsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.searchDocuments(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, which owns this collection of documents. - * Format: projects/{project_number}/locations/{location}. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the end user, used to enforce access - * control and improve the search quality of the service. - * @param {google.cloud.contentwarehouse.v1.DocumentQuery} request.documentQuery - * Query used to search against documents (keyword, filters, etc.). - * @param {number} request.offset - * An integer that specifies the current offset (that is, starting result - * location, amongst the documents deemed by the API as relevant) in search - * results. This field is only considered if {@link google.cloud.contentwarehouse.v1.SearchDocumentsRequest.page_token|page_token} is unset. - * - * The maximum allowed value is 5000. Otherwise an error is thrown. - * - * For example, 0 means to return results starting from the first matching - * document, and 10 means to return from the 11th document. This can be used - * for pagination, (for example, pageSize = 10 and offset = 10 means to return - * from the second page). - * @param {number} request.pageSize - * A limit on the number of documents returned in the search results. - * Increasing this value above the default value of 10 can increase search - * response time. The value can be between 1 and 100. - * @param {string} request.pageToken - * The token specifying the current offset within search results. - * See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.next_page_token|SearchDocumentsResponse.next_page_token} for an explanation of how - * to obtain the next set of query results. - * @param {string} request.orderBy - * The criteria determining how search results are sorted. For non-empty - * query, default is `"relevance desc"`. For empty query, default is - * `"upload_date desc"`. - * - * Supported options are: - * - * * `"relevance desc"`: By relevance descending, as determined by the API - * algorithms. - * * `"upload_date desc"`: By upload date descending. - * * `"upload_date"`: By upload date ascending. - * * `"update_date desc"`: By last updated date descending. - * * `"update_date"`: By last updated date ascending. - * @param {number[]} request.histogramQueries - * An expression specifying a histogram request against matching - * documents. Expression syntax is an aggregation function call with - * histogram facets and other options. - * - * The following aggregation functions are supported: - * - * * `count(string_histogram_facet)`: Count the number of matching entities - * for each distinct attribute value. - * - * Data types: - * - * * Histogram facet (aka filterable properties): Facet names with format - * <schema id>.<facet>. Facets will have the - * format of: `{@link a-zA-Z0-9_:/-.|a-zA-Z}`. If the facet is a child - * facet, then the parent hierarchy needs to be specified separated by - * dots in the prefix after the schema id. Thus, the format for a multi- - * level facet is: <schema id>.<parent facet name>. - * <child facet name>. Example: - * schema123.root_parent_facet.middle_facet.child_facet - * * DocumentSchemaId: (with no schema id prefix) to get - * histograms for each document type (returns the schema id path, e.g. - * projects/12345/locations/us-west/documentSchemas/abc123). - * - * Example expression: - * - * * Document type counts: - * count('DocumentSchemaId') - * - * * For schema id, abc123, get the counts for MORTGAGE_TYPE: - * count('abc123.MORTGAGE_TYPE') - * @param {boolean} request.requireTotalSize - * Optional. Controls if the search document request requires the return of a total size - * of matched documents. See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.total_size|SearchDocumentsResponse.total_size}. - * - * Enabling this flag may adversely impact performance. Hint: If this is - * used with pagination, set this flag on the initial query but set this - * to false on subsequent page calls (keep the total count locally). - * - * Defaults to false. - * @param {number} request.qaSizeLimit - * Experimental, do not use. - * The limit on the number of documents returned for the question-answering - * feature. To enable the question-answering feature, set - * {@link |DocumentQuery].[is_nl_query} to true. - * @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 [MatchingDocument]{@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument} 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 `searchDocumentsAsync()` - * 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. - */ - searchDocumentsStream( - request?: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, - 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['searchDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchDocuments.createStream( - this.innerApiCalls.searchDocuments as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchDocuments`, 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, which owns this collection of documents. - * Format: projects/{project_number}/locations/{location}. - * @param {google.cloud.contentwarehouse.v1.RequestMetadata} request.requestMetadata - * The meta information collected about the end user, used to enforce access - * control and improve the search quality of the service. - * @param {google.cloud.contentwarehouse.v1.DocumentQuery} request.documentQuery - * Query used to search against documents (keyword, filters, etc.). - * @param {number} request.offset - * An integer that specifies the current offset (that is, starting result - * location, amongst the documents deemed by the API as relevant) in search - * results. This field is only considered if {@link google.cloud.contentwarehouse.v1.SearchDocumentsRequest.page_token|page_token} is unset. - * - * The maximum allowed value is 5000. Otherwise an error is thrown. - * - * For example, 0 means to return results starting from the first matching - * document, and 10 means to return from the 11th document. This can be used - * for pagination, (for example, pageSize = 10 and offset = 10 means to return - * from the second page). - * @param {number} request.pageSize - * A limit on the number of documents returned in the search results. - * Increasing this value above the default value of 10 can increase search - * response time. The value can be between 1 and 100. - * @param {string} request.pageToken - * The token specifying the current offset within search results. - * See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.next_page_token|SearchDocumentsResponse.next_page_token} for an explanation of how - * to obtain the next set of query results. - * @param {string} request.orderBy - * The criteria determining how search results are sorted. For non-empty - * query, default is `"relevance desc"`. For empty query, default is - * `"upload_date desc"`. - * - * Supported options are: - * - * * `"relevance desc"`: By relevance descending, as determined by the API - * algorithms. - * * `"upload_date desc"`: By upload date descending. - * * `"upload_date"`: By upload date ascending. - * * `"update_date desc"`: By last updated date descending. - * * `"update_date"`: By last updated date ascending. - * @param {number[]} request.histogramQueries - * An expression specifying a histogram request against matching - * documents. Expression syntax is an aggregation function call with - * histogram facets and other options. - * - * The following aggregation functions are supported: - * - * * `count(string_histogram_facet)`: Count the number of matching entities - * for each distinct attribute value. - * - * Data types: - * - * * Histogram facet (aka filterable properties): Facet names with format - * <schema id>.<facet>. Facets will have the - * format of: `{@link a-zA-Z0-9_:/-.|a-zA-Z}`. If the facet is a child - * facet, then the parent hierarchy needs to be specified separated by - * dots in the prefix after the schema id. Thus, the format for a multi- - * level facet is: <schema id>.<parent facet name>. - * <child facet name>. Example: - * schema123.root_parent_facet.middle_facet.child_facet - * * DocumentSchemaId: (with no schema id prefix) to get - * histograms for each document type (returns the schema id path, e.g. - * projects/12345/locations/us-west/documentSchemas/abc123). - * - * Example expression: - * - * * Document type counts: - * count('DocumentSchemaId') - * - * * For schema id, abc123, get the counts for MORTGAGE_TYPE: - * count('abc123.MORTGAGE_TYPE') - * @param {boolean} request.requireTotalSize - * Optional. Controls if the search document request requires the return of a total size - * of matched documents. See {@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.total_size|SearchDocumentsResponse.total_size}. - * - * Enabling this flag may adversely impact performance. Hint: If this is - * used with pagination, set this flag on the initial query but set this - * to false on subsequent page calls (keep the total count locally). - * - * Defaults to false. - * @param {number} request.qaSizeLimit - * Experimental, do not use. - * The limit on the number of documents returned for the question-answering - * feature. To enable the question-answering feature, set - * {@link |DocumentQuery].[is_nl_query} to true. - * @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 - * [MatchingDocument]{@link google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/document_service.search_documents.js - * region_tag:contentwarehouse_v1_generated_DocumentService_SearchDocuments_async - */ - searchDocumentsAsync( - request?: protos.google.cloud.contentwarehouse.v1.ISearchDocumentsRequest, - 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['searchDocuments']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchDocuments.asyncIterate( - this.innerApiCalls['searchDocuments'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified documentLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document - * @param {string} document_link - * @returns {string} Resource name string. - */ - documentLinkPath(project:string,location:string,document:string,documentLink:string) { - return this.pathTemplates.documentLinkPathTemplate.render({ - project: project, - location: location, - document: document, - document_link: documentLink, - }); - } - - /** - * Parse the project from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).project; - } - - /** - * Parse the location from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).location; - } - - /** - * Parse the document from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document; - } - - /** - * Parse the document_link from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the document_link. - */ - matchDocumentLinkFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document_link; - } - - /** - * Return a fully-qualified documentSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document_schema - * @returns {string} Resource name string. - */ - documentSchemaPath(project:string,location:string,documentSchema:string) { - return this.pathTemplates.documentSchemaPathTemplate.render({ - project: project, - location: location, - document_schema: documentSchema, - }); - } - - /** - * Parse the project from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).project; - } - - /** - * Parse the location from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).location; - } - - /** - * Parse the document_schema from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the document_schema. - */ - matchDocumentSchemaFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).document_schema; - } - - /** - * Return a fully-qualified projectLocationDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDocumentPath(project:string,location:string,document:string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.render({ - project: project, - location: location, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).location; - } - - /** - * Parse the document from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDocumentsReferenceId resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} reference_id - * @returns {string} Resource name string. - */ - projectLocationDocumentsReferenceIdPath(project:string,location:string,referenceId:string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render({ - project: project, - location: location, - reference_id: referenceId, - }); - } - - /** - * Parse the project from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).project; - } - - /** - * Parse the location from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).location; - } - - /** - * Parse the reference_id from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the reference_id. - */ - matchReferenceIdFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).reference_id; - } - - /** - * Return a fully-qualified ruleSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} rule_set - * @returns {string} Resource name string. - */ - ruleSetPath(project:string,location:string,ruleSet:string) { - return this.pathTemplates.ruleSetPathTemplate.render({ - project: project, - location: location, - rule_set: ruleSet, - }); - } - - /** - * Parse the project from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).project; - } - - /** - * Parse the location from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).location; - } - - /** - * Parse the rule_set from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the rule_set. - */ - matchRuleSetFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).rule_set; - } - - /** - * Return a fully-qualified synonymSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} context - * @returns {string} Resource name string. - */ - synonymSetPath(project:string,location:string,context:string) { - return this.pathTemplates.synonymSetPathTemplate.render({ - project: project, - location: location, - context: context, - }); - } - - /** - * Parse the project from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).project; - } - - /** - * Parse the location from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).location; - } - - /** - * Parse the context from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the context. - */ - matchContextFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).context; - } - - /** - * 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.documentServiceStub && !this._terminated) { - return this.documentServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client_config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client_config.json deleted file mode 100644 index 93f35fd6410..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_client_config.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "interfaces": { - "google.cloud.contentwarehouse.v1.DocumentService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateDocument": { - "timeout_millis": 180000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetDocument": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateDocument": { - "timeout_millis": 180000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteDocument": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SearchDocuments": { - "timeout_millis": 180000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "FetchAcl": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "SetAcl": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_proto_list.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_proto_list.json deleted file mode 100644 index e85ca71c0c6..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/document_service_proto_list.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - "../../protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/common.proto", - "../../protos/google/cloud/contentwarehouse/v1/document.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_link_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_schema.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_schema_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/filters.proto", - "../../protos/google/cloud/contentwarehouse/v1/histogram.proto", - "../../protos/google/cloud/contentwarehouse/v1/rule_engine.proto", - "../../protos/google/cloud/contentwarehouse/v1/ruleset_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto", - "../../protos/google/cloud/documentai/v1/barcode.proto", - "../../protos/google/cloud/documentai/v1/document.proto", - "../../protos/google/cloud/documentai/v1/geometry.proto" -] diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/gapic_metadata.json deleted file mode 100644 index e15eab1c98f..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,359 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.contentwarehouse.v1", - "libraryPackage": "@google-cloud/contentwarehouse", - "services": { - "DocumentLinkService": { - "clients": { - "grpc": { - "libraryClient": "DocumentLinkServiceClient", - "rpcs": { - "ListLinkedTargets": { - "methods": [ - "listLinkedTargets" - ] - }, - "CreateDocumentLink": { - "methods": [ - "createDocumentLink" - ] - }, - "DeleteDocumentLink": { - "methods": [ - "deleteDocumentLink" - ] - }, - "ListLinkedSources": { - "methods": [ - "listLinkedSources", - "listLinkedSourcesStream", - "listLinkedSourcesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentLinkServiceClient", - "rpcs": { - "ListLinkedTargets": { - "methods": [ - "listLinkedTargets" - ] - }, - "CreateDocumentLink": { - "methods": [ - "createDocumentLink" - ] - }, - "DeleteDocumentLink": { - "methods": [ - "deleteDocumentLink" - ] - }, - "ListLinkedSources": { - "methods": [ - "listLinkedSources", - "listLinkedSourcesStream", - "listLinkedSourcesAsync" - ] - } - } - } - } - }, - "DocumentSchemaService": { - "clients": { - "grpc": { - "libraryClient": "DocumentSchemaServiceClient", - "rpcs": { - "CreateDocumentSchema": { - "methods": [ - "createDocumentSchema" - ] - }, - "UpdateDocumentSchema": { - "methods": [ - "updateDocumentSchema" - ] - }, - "GetDocumentSchema": { - "methods": [ - "getDocumentSchema" - ] - }, - "DeleteDocumentSchema": { - "methods": [ - "deleteDocumentSchema" - ] - }, - "ListDocumentSchemas": { - "methods": [ - "listDocumentSchemas", - "listDocumentSchemasStream", - "listDocumentSchemasAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentSchemaServiceClient", - "rpcs": { - "CreateDocumentSchema": { - "methods": [ - "createDocumentSchema" - ] - }, - "UpdateDocumentSchema": { - "methods": [ - "updateDocumentSchema" - ] - }, - "GetDocumentSchema": { - "methods": [ - "getDocumentSchema" - ] - }, - "DeleteDocumentSchema": { - "methods": [ - "deleteDocumentSchema" - ] - }, - "ListDocumentSchemas": { - "methods": [ - "listDocumentSchemas", - "listDocumentSchemasStream", - "listDocumentSchemasAsync" - ] - } - } - } - } - }, - "DocumentService": { - "clients": { - "grpc": { - "libraryClient": "DocumentServiceClient", - "rpcs": { - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, - "GetDocument": { - "methods": [ - "getDocument" - ] - }, - "UpdateDocument": { - "methods": [ - "updateDocument" - ] - }, - "DeleteDocument": { - "methods": [ - "deleteDocument" - ] - }, - "FetchAcl": { - "methods": [ - "fetchAcl" - ] - }, - "SetAcl": { - "methods": [ - "setAcl" - ] - }, - "SearchDocuments": { - "methods": [ - "searchDocuments", - "searchDocumentsStream", - "searchDocumentsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentServiceClient", - "rpcs": { - "CreateDocument": { - "methods": [ - "createDocument" - ] - }, - "GetDocument": { - "methods": [ - "getDocument" - ] - }, - "UpdateDocument": { - "methods": [ - "updateDocument" - ] - }, - "DeleteDocument": { - "methods": [ - "deleteDocument" - ] - }, - "FetchAcl": { - "methods": [ - "fetchAcl" - ] - }, - "SetAcl": { - "methods": [ - "setAcl" - ] - }, - "SearchDocuments": { - "methods": [ - "searchDocuments", - "searchDocumentsStream", - "searchDocumentsAsync" - ] - } - } - } - } - }, - "RuleSetService": { - "clients": { - "grpc": { - "libraryClient": "RuleSetServiceClient", - "rpcs": { - "CreateRuleSet": { - "methods": [ - "createRuleSet" - ] - }, - "GetRuleSet": { - "methods": [ - "getRuleSet" - ] - }, - "UpdateRuleSet": { - "methods": [ - "updateRuleSet" - ] - }, - "DeleteRuleSet": { - "methods": [ - "deleteRuleSet" - ] - }, - "ListRuleSets": { - "methods": [ - "listRuleSets", - "listRuleSetsStream", - "listRuleSetsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "RuleSetServiceClient", - "rpcs": { - "CreateRuleSet": { - "methods": [ - "createRuleSet" - ] - }, - "GetRuleSet": { - "methods": [ - "getRuleSet" - ] - }, - "UpdateRuleSet": { - "methods": [ - "updateRuleSet" - ] - }, - "DeleteRuleSet": { - "methods": [ - "deleteRuleSet" - ] - }, - "ListRuleSets": { - "methods": [ - "listRuleSets", - "listRuleSetsStream", - "listRuleSetsAsync" - ] - } - } - } - } - }, - "SynonymSetService": { - "clients": { - "grpc": { - "libraryClient": "SynonymSetServiceClient", - "rpcs": { - "CreateSynonymSet": { - "methods": [ - "createSynonymSet" - ] - }, - "GetSynonymSet": { - "methods": [ - "getSynonymSet" - ] - }, - "UpdateSynonymSet": { - "methods": [ - "updateSynonymSet" - ] - }, - "DeleteSynonymSet": { - "methods": [ - "deleteSynonymSet" - ] - }, - "ListSynonymSets": { - "methods": [ - "listSynonymSets", - "listSynonymSetsStream", - "listSynonymSetsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "SynonymSetServiceClient", - "rpcs": { - "CreateSynonymSet": { - "methods": [ - "createSynonymSet" - ] - }, - "GetSynonymSet": { - "methods": [ - "getSynonymSet" - ] - }, - "UpdateSynonymSet": { - "methods": [ - "updateSynonymSet" - ] - }, - "DeleteSynonymSet": { - "methods": [ - "deleteSynonymSet" - ] - }, - "ListSynonymSets": { - "methods": [ - "listSynonymSets", - "listSynonymSetsStream", - "listSynonymSetsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/index.ts deleted file mode 100644 index de01f8e3028..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {DocumentLinkServiceClient} from './document_link_service_client'; -export {DocumentSchemaServiceClient} from './document_schema_service_client'; -export {DocumentServiceClient} from './document_service_client'; -export {RuleSetServiceClient} from './rule_set_service_client'; -export {SynonymSetServiceClient} from './synonym_set_service_client'; diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client.ts deleted file mode 100644 index 822720fb9dc..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client.ts +++ /dev/null @@ -1,1144 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/rule_set_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './rule_set_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service to manage customer specific RuleSets. - * @class - * @memberof v1 - */ -export class RuleSetServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - ruleSetServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of RuleSetServiceClient. - * - * @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 RuleSetServiceClient({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 RuleSetServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - documentLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}' - ), - documentSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documentSchemas/{document_schema}' - ), - projectLocationDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/{document}' - ), - projectLocationDocumentsReferenceIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/referenceId/{reference_id}' - ), - ruleSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ruleSets/{rule_set}' - ), - synonymSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/synonymSets/{context}' - ), - }; - - // 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 = { - listRuleSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'ruleSets') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.contentwarehouse.v1.RuleSetService', 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.ruleSetServiceStub) { - return this.ruleSetServiceStub; - } - - // Put together the "service stub" for - // google.cloud.contentwarehouse.v1.RuleSetService. - this.ruleSetServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.contentwarehouse.v1.RuleSetService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.contentwarehouse.v1.RuleSetService, - 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 ruleSetServiceStubMethods = - ['createRuleSet', 'getRuleSet', 'updateRuleSet', 'deleteRuleSet', 'listRuleSets']; - for (const methodName of ruleSetServiceStubMethods) { - const callPromise = this.ruleSetServiceStub.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.ruleSetServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'contentwarehouse.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 'contentwarehouse.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 ruleset. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent name. - * Format: projects/{project_number}/locations/{location}. - * @param {google.cloud.contentwarehouse.v1.RuleSet} request.ruleSet - * Required. The rule set to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/rule_set_service.create_rule_set.js - * region_tag:contentwarehouse_v1_generated_RuleSetService_CreateRuleSet_async - */ - createRuleSet( - request?: protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|undefined, {}|undefined - ]>; - createRuleSet( - request: protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|null|undefined, - {}|null|undefined>): void; - createRuleSet( - request: protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|null|undefined, - {}|null|undefined>): void; - createRuleSet( - request?: protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.ICreateRuleSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createRuleSet(request, options, callback); - } -/** - * Gets a ruleset. Returns NOT_FOUND if the ruleset does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the rule set to retrieve. - * Format: - * projects/{project_number}/locations/{location}/ruleSets/{rule_set_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 [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/rule_set_service.get_rule_set.js - * region_tag:contentwarehouse_v1_generated_RuleSetService_GetRuleSet_async - */ - getRuleSet( - request?: protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|undefined, {}|undefined - ]>; - getRuleSet( - request: protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|null|undefined, - {}|null|undefined>): void; - getRuleSet( - request: protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|null|undefined, - {}|null|undefined>): void; - getRuleSet( - request?: protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IGetRuleSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getRuleSet(request, options, callback); - } -/** - * Updates a ruleset. Returns INVALID_ARGUMENT if the name of the ruleset - * is non-empty and does not equal the existing name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the rule set to update. - * Format: - * projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. - * @param {google.cloud.contentwarehouse.v1.RuleSet} request.ruleSet - * Required. The rule set to update. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/rule_set_service.update_rule_set.js - * region_tag:contentwarehouse_v1_generated_RuleSetService_UpdateRuleSet_async - */ - updateRuleSet( - request?: protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|undefined, {}|undefined - ]>; - updateRuleSet( - request: protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|null|undefined, - {}|null|undefined>): void; - updateRuleSet( - request: protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|null|undefined, - {}|null|undefined>): void; - updateRuleSet( - request?: protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IRuleSet, - protos.google.cloud.contentwarehouse.v1.IUpdateRuleSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.updateRuleSet(request, options, callback); - } -/** - * Deletes a ruleset. Returns NOT_FOUND if the document does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the rule set to delete. - * Format: - * projects/{project_number}/locations/{location}/ruleSets/{rule_set_id}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/rule_set_service.delete_rule_set.js - * region_tag:contentwarehouse_v1_generated_RuleSetService_DeleteRuleSet_async - */ - deleteRuleSet( - request?: protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|undefined, {}|undefined - ]>; - deleteRuleSet( - request: protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|null|undefined, - {}|null|undefined>): void; - deleteRuleSet( - request: protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|null|undefined, - {}|null|undefined>): void; - deleteRuleSet( - request?: protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteRuleSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteRuleSet(request, options, callback); - } - - /** - * Lists rulesets. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of document. - * Format: projects/{project_number}/locations/{location}. - * @param {number} request.pageSize - * The maximum number of rule sets to return. The service may return - * fewer than this value. - * If unspecified, at most 50 rule sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListRuleSets` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListRuleSets` - * must match the call that provided the page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet}. - * 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 `listRuleSetsAsync()` - * 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. - */ - listRuleSets( - request?: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IRuleSet[], - protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest|null, - protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse - ]>; - listRuleSets( - request: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, - protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IRuleSet>): void; - listRuleSets( - request: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, - callback: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, - protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IRuleSet>): void; - listRuleSets( - request?: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, - protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IRuleSet>, - callback?: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, - protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.IRuleSet>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.IRuleSet[], - protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest|null, - protos.google.cloud.contentwarehouse.v1.IListRuleSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listRuleSets(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, which owns this collection of document. - * Format: projects/{project_number}/locations/{location}. - * @param {number} request.pageSize - * The maximum number of rule sets to return. The service may return - * fewer than this value. - * If unspecified, at most 50 rule sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListRuleSets` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListRuleSets` - * must match the call that provided the page token. - * @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 [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet} 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 `listRuleSetsAsync()` - * 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. - */ - listRuleSetsStream( - request?: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, - 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['listRuleSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRuleSets.createStream( - this.innerApiCalls.listRuleSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listRuleSets`, 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, which owns this collection of document. - * Format: projects/{project_number}/locations/{location}. - * @param {number} request.pageSize - * The maximum number of rule sets to return. The service may return - * fewer than this value. - * If unspecified, at most 50 rule sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListRuleSets` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListRuleSets` - * must match the call that provided the 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 - * [RuleSet]{@link google.cloud.contentwarehouse.v1.RuleSet}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/rule_set_service.list_rule_sets.js - * region_tag:contentwarehouse_v1_generated_RuleSetService_ListRuleSets_async - */ - listRuleSetsAsync( - request?: protos.google.cloud.contentwarehouse.v1.IListRuleSetsRequest, - 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['listRuleSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listRuleSets.asyncIterate( - this.innerApiCalls['listRuleSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified documentLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document - * @param {string} document_link - * @returns {string} Resource name string. - */ - documentLinkPath(project:string,location:string,document:string,documentLink:string) { - return this.pathTemplates.documentLinkPathTemplate.render({ - project: project, - location: location, - document: document, - document_link: documentLink, - }); - } - - /** - * Parse the project from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).project; - } - - /** - * Parse the location from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).location; - } - - /** - * Parse the document from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document; - } - - /** - * Parse the document_link from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the document_link. - */ - matchDocumentLinkFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document_link; - } - - /** - * Return a fully-qualified documentSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document_schema - * @returns {string} Resource name string. - */ - documentSchemaPath(project:string,location:string,documentSchema:string) { - return this.pathTemplates.documentSchemaPathTemplate.render({ - project: project, - location: location, - document_schema: documentSchema, - }); - } - - /** - * Parse the project from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).project; - } - - /** - * Parse the location from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).location; - } - - /** - * Parse the document_schema from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the document_schema. - */ - matchDocumentSchemaFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).document_schema; - } - - /** - * Return a fully-qualified projectLocationDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDocumentPath(project:string,location:string,document:string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.render({ - project: project, - location: location, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).location; - } - - /** - * Parse the document from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDocumentsReferenceId resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} reference_id - * @returns {string} Resource name string. - */ - projectLocationDocumentsReferenceIdPath(project:string,location:string,referenceId:string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render({ - project: project, - location: location, - reference_id: referenceId, - }); - } - - /** - * Parse the project from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).project; - } - - /** - * Parse the location from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).location; - } - - /** - * Parse the reference_id from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the reference_id. - */ - matchReferenceIdFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).reference_id; - } - - /** - * Return a fully-qualified ruleSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} rule_set - * @returns {string} Resource name string. - */ - ruleSetPath(project:string,location:string,ruleSet:string) { - return this.pathTemplates.ruleSetPathTemplate.render({ - project: project, - location: location, - rule_set: ruleSet, - }); - } - - /** - * Parse the project from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).project; - } - - /** - * Parse the location from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).location; - } - - /** - * Parse the rule_set from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the rule_set. - */ - matchRuleSetFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).rule_set; - } - - /** - * Return a fully-qualified synonymSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} context - * @returns {string} Resource name string. - */ - synonymSetPath(project:string,location:string,context:string) { - return this.pathTemplates.synonymSetPathTemplate.render({ - project: project, - location: location, - context: context, - }); - } - - /** - * Parse the project from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).project; - } - - /** - * Parse the location from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).location; - } - - /** - * Parse the context from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the context. - */ - matchContextFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).context; - } - - /** - * 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.ruleSetServiceStub && !this._terminated) { - return this.ruleSetServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client_config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client_config.json deleted file mode 100644 index e5e5bf93f5d..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_client_config.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "interfaces": { - "google.cloud.contentwarehouse.v1.RuleSetService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateRuleSet": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetRuleSet": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateRuleSet": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteRuleSet": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListRuleSets": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_proto_list.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_proto_list.json deleted file mode 100644 index e85ca71c0c6..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/rule_set_service_proto_list.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - "../../protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/common.proto", - "../../protos/google/cloud/contentwarehouse/v1/document.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_link_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_schema.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_schema_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/filters.proto", - "../../protos/google/cloud/contentwarehouse/v1/histogram.proto", - "../../protos/google/cloud/contentwarehouse/v1/rule_engine.proto", - "../../protos/google/cloud/contentwarehouse/v1/ruleset_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto", - "../../protos/google/cloud/documentai/v1/barcode.proto", - "../../protos/google/cloud/documentai/v1/document.proto", - "../../protos/google/cloud/documentai/v1/geometry.proto" -] diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client.ts deleted file mode 100644 index 2c6233fa404..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client.ts +++ /dev/null @@ -1,1150 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/synonym_set_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './synonym_set_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * A Service that manage/custom customer specified SynonymSets. - * @class - * @memberof v1 - */ -export class SynonymSetServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - synonymSetServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of SynonymSetServiceClient. - * - * @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 SynonymSetServiceClient({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 SynonymSetServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - documentLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/{document}/documentLinks/{document_link}' - ), - documentSchemaPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documentSchemas/{document_schema}' - ), - projectLocationDocumentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/{document}' - ), - projectLocationDocumentsReferenceIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/documents/referenceId/{reference_id}' - ), - ruleSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ruleSets/{rule_set}' - ), - synonymSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/synonymSets/{context}' - ), - }; - - // 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 = { - listSynonymSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'synonymSets') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.contentwarehouse.v1.SynonymSetService', 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.synonymSetServiceStub) { - return this.synonymSetServiceStub; - } - - // Put together the "service stub" for - // google.cloud.contentwarehouse.v1.SynonymSetService. - this.synonymSetServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.contentwarehouse.v1.SynonymSetService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.contentwarehouse.v1.SynonymSetService, - 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 synonymSetServiceStubMethods = - ['createSynonymSet', 'getSynonymSet', 'updateSynonymSet', 'deleteSynonymSet', 'listSynonymSets']; - for (const methodName of synonymSetServiceStubMethods) { - const callPromise = this.synonymSetServiceStub.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.synonymSetServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'contentwarehouse.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 'contentwarehouse.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 SynonymSet for a single context. - * Throws an ALREADY_EXISTS exception if a synonymset already exists - * for the context. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent name. - * Format: projects/{project_number}/locations/{location}. - * @param {google.cloud.contentwarehouse.v1.SynonymSet} request.synonymSet - * Required. The synonymSet to be created for a context - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/synonym_set_service.create_synonym_set.js - * region_tag:contentwarehouse_v1_generated_SynonymSetService_CreateSynonymSet_async - */ - createSynonymSet( - request?: protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|undefined, {}|undefined - ]>; - createSynonymSet( - request: protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|null|undefined, - {}|null|undefined>): void; - createSynonymSet( - request: protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|null|undefined, - {}|null|undefined>): void; - createSynonymSet( - request?: protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.ICreateSynonymSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.createSynonymSet(request, options, callback); - } -/** - * Gets a SynonymSet for a particular context. - * Throws a NOT_FOUND exception if the Synonymset - * does not exist - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the synonymSet to retrieve - * Format: - * projects/{project_number}/locations/{location}/synonymSets/{context}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/synonym_set_service.get_synonym_set.js - * region_tag:contentwarehouse_v1_generated_SynonymSetService_GetSynonymSet_async - */ - getSynonymSet( - request?: protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|undefined, {}|undefined - ]>; - getSynonymSet( - request: protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|null|undefined, - {}|null|undefined>): void; - getSynonymSet( - request: protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|null|undefined, - {}|null|undefined>): void; - getSynonymSet( - request?: protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IGetSynonymSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.getSynonymSet(request, options, callback); - } -/** - * Remove the existing SynonymSet for the context and replaces it - * with a new one. - * Throws a NOT_FOUND exception if the SynonymSet is not found. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the synonymSet to update - * Format: - * projects/{project_number}/locations/{location}/synonymSets/{context}. - * @param {google.cloud.contentwarehouse.v1.SynonymSet} request.synonymSet - * Required. The synonymSet to be updated for the customer - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/synonym_set_service.update_synonym_set.js - * region_tag:contentwarehouse_v1_generated_SynonymSetService_UpdateSynonymSet_async - */ - updateSynonymSet( - request?: protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|undefined, {}|undefined - ]>; - updateSynonymSet( - request: protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|null|undefined, - {}|null|undefined>): void; - updateSynonymSet( - request: protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest, - callback: Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|null|undefined, - {}|null|undefined>): void; - updateSynonymSet( - request?: protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ISynonymSet, - protos.google.cloud.contentwarehouse.v1.IUpdateSynonymSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.updateSynonymSet(request, options, callback); - } -/** - * Deletes a SynonymSet for a given context. - * Throws a NOT_FOUND exception if the SynonymSet is not found. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the synonymSet to delete - * Format: - * projects/{project_number}/locations/{location}/synonymSets/{context}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/synonym_set_service.delete_synonym_set.js - * region_tag:contentwarehouse_v1_generated_SynonymSetService_DeleteSynonymSet_async - */ - deleteSynonymSet( - request?: protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|undefined, {}|undefined - ]>; - deleteSynonymSet( - request: protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|null|undefined, - {}|null|undefined>): void; - deleteSynonymSet( - request: protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|null|undefined, - {}|null|undefined>): void; - deleteSynonymSet( - request?: protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.contentwarehouse.v1.IDeleteSynonymSetRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.deleteSynonymSet(request, options, callback); - } - - /** - * Returns all SynonymSets (for all contexts) for the specified location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent name. - * Format: projects/{project_number}/locations/{location}. - * @param {number} request.pageSize - * The maximum number of synonymSets to return. The service may return - * fewer than this value. - * If unspecified, at most 50 rule sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListSynonymSets` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListSynonymSets` - * must match the call that provided the page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet}. - * 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 `listSynonymSetsAsync()` - * 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. - */ - listSynonymSets( - request?: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ISynonymSet[], - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest|null, - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse - ]>; - listSynonymSets( - request: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.ISynonymSet>): void; - listSynonymSets( - request: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, - callback: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.ISynonymSet>): void; - listSynonymSets( - request?: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.ISynonymSet>, - callback?: PaginationCallback< - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse|null|undefined, - protos.google.cloud.contentwarehouse.v1.ISynonymSet>): - Promise<[ - protos.google.cloud.contentwarehouse.v1.ISynonymSet[], - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest|null, - protos.google.cloud.contentwarehouse.v1.IListSynonymSetsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as 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.listSynonymSets(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 name. - * Format: projects/{project_number}/locations/{location}. - * @param {number} request.pageSize - * The maximum number of synonymSets to return. The service may return - * fewer than this value. - * If unspecified, at most 50 rule sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListSynonymSets` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListSynonymSets` - * must match the call that provided the page token. - * @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 [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet} 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 `listSynonymSetsAsync()` - * 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. - */ - listSynonymSetsStream( - request?: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, - 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['listSynonymSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSynonymSets.createStream( - this.innerApiCalls.listSynonymSets as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listSynonymSets`, 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 name. - * Format: projects/{project_number}/locations/{location}. - * @param {number} request.pageSize - * The maximum number of synonymSets to return. The service may return - * fewer than this value. - * If unspecified, at most 50 rule sets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListSynonymSets` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListSynonymSets` - * must match the call that provided the 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 - * [SynonymSet]{@link google.cloud.contentwarehouse.v1.SynonymSet}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/synonym_set_service.list_synonym_sets.js - * region_tag:contentwarehouse_v1_generated_SynonymSetService_ListSynonymSets_async - */ - listSynonymSetsAsync( - request?: protos.google.cloud.contentwarehouse.v1.IListSynonymSetsRequest, - 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['listSynonymSets']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listSynonymSets.asyncIterate( - this.innerApiCalls['listSynonymSets'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified documentLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document - * @param {string} document_link - * @returns {string} Resource name string. - */ - documentLinkPath(project:string,location:string,document:string,documentLink:string) { - return this.pathTemplates.documentLinkPathTemplate.render({ - project: project, - location: location, - document: document, - document_link: documentLink, - }); - } - - /** - * Parse the project from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).project; - } - - /** - * Parse the location from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).location; - } - - /** - * Parse the document from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document; - } - - /** - * Parse the document_link from DocumentLink resource. - * - * @param {string} documentLinkName - * A fully-qualified path representing DocumentLink resource. - * @returns {string} A string representing the document_link. - */ - matchDocumentLinkFromDocumentLinkName(documentLinkName: string) { - return this.pathTemplates.documentLinkPathTemplate.match(documentLinkName).document_link; - } - - /** - * Return a fully-qualified documentSchema resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document_schema - * @returns {string} Resource name string. - */ - documentSchemaPath(project:string,location:string,documentSchema:string) { - return this.pathTemplates.documentSchemaPathTemplate.render({ - project: project, - location: location, - document_schema: documentSchema, - }); - } - - /** - * Parse the project from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).project; - } - - /** - * Parse the location from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).location; - } - - /** - * Parse the document_schema from DocumentSchema resource. - * - * @param {string} documentSchemaName - * A fully-qualified path representing DocumentSchema resource. - * @returns {string} A string representing the document_schema. - */ - matchDocumentSchemaFromDocumentSchemaName(documentSchemaName: string) { - return this.pathTemplates.documentSchemaPathTemplate.match(documentSchemaName).document_schema; - } - - /** - * Return a fully-qualified projectLocationDocument resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} document - * @returns {string} Resource name string. - */ - projectLocationDocumentPath(project:string,location:string,document:string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.render({ - project: project, - location: location, - document: document, - }); - } - - /** - * Parse the project from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).project; - } - - /** - * Parse the location from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).location; - } - - /** - * Parse the document from ProjectLocationDocument resource. - * - * @param {string} projectLocationDocumentName - * A fully-qualified path representing project_location_document resource. - * @returns {string} A string representing the document. - */ - matchDocumentFromProjectLocationDocumentName(projectLocationDocumentName: string) { - return this.pathTemplates.projectLocationDocumentPathTemplate.match(projectLocationDocumentName).document; - } - - /** - * Return a fully-qualified projectLocationDocumentsReferenceId resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} reference_id - * @returns {string} Resource name string. - */ - projectLocationDocumentsReferenceIdPath(project:string,location:string,referenceId:string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render({ - project: project, - location: location, - reference_id: referenceId, - }); - } - - /** - * Parse the project from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).project; - } - - /** - * Parse the location from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).location; - } - - /** - * Parse the reference_id from ProjectLocationDocumentsReferenceId resource. - * - * @param {string} projectLocationDocumentsReferenceIdName - * A fully-qualified path representing project_location_documents_reference_id resource. - * @returns {string} A string representing the reference_id. - */ - matchReferenceIdFromProjectLocationDocumentsReferenceIdName(projectLocationDocumentsReferenceIdName: string) { - return this.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match(projectLocationDocumentsReferenceIdName).reference_id; - } - - /** - * Return a fully-qualified ruleSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} rule_set - * @returns {string} Resource name string. - */ - ruleSetPath(project:string,location:string,ruleSet:string) { - return this.pathTemplates.ruleSetPathTemplate.render({ - project: project, - location: location, - rule_set: ruleSet, - }); - } - - /** - * Parse the project from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).project; - } - - /** - * Parse the location from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).location; - } - - /** - * Parse the rule_set from RuleSet resource. - * - * @param {string} ruleSetName - * A fully-qualified path representing RuleSet resource. - * @returns {string} A string representing the rule_set. - */ - matchRuleSetFromRuleSetName(ruleSetName: string) { - return this.pathTemplates.ruleSetPathTemplate.match(ruleSetName).rule_set; - } - - /** - * Return a fully-qualified synonymSet resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} context - * @returns {string} Resource name string. - */ - synonymSetPath(project:string,location:string,context:string) { - return this.pathTemplates.synonymSetPathTemplate.render({ - project: project, - location: location, - context: context, - }); - } - - /** - * Parse the project from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the project. - */ - matchProjectFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).project; - } - - /** - * Parse the location from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the location. - */ - matchLocationFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).location; - } - - /** - * Parse the context from SynonymSet resource. - * - * @param {string} synonymSetName - * A fully-qualified path representing SynonymSet resource. - * @returns {string} A string representing the context. - */ - matchContextFromSynonymSetName(synonymSetName: string) { - return this.pathTemplates.synonymSetPathTemplate.match(synonymSetName).context; - } - - /** - * 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.synonymSetServiceStub && !this._terminated) { - return this.synonymSetServiceStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client_config.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client_config.json deleted file mode 100644 index 3c3408c02f7..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_client_config.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "interfaces": { - "google.cloud.contentwarehouse.v1.SynonymSetService": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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 - }, - "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 10000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateSynonymSet": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetSynonymSet": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - }, - "UpdateSynonymSet": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteSynonymSet": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListSynonymSets": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_proto_list.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_proto_list.json deleted file mode 100644 index e85ca71c0c6..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/src/v1/synonym_set_service_proto_list.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - "../../protos/google/cloud/contentwarehouse/v1/async_document_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/common.proto", - "../../protos/google/cloud/contentwarehouse/v1/document.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_link_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_schema.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_schema_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/document_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/filters.proto", - "../../protos/google/cloud/contentwarehouse/v1/histogram.proto", - "../../protos/google/cloud/contentwarehouse/v1/rule_engine.proto", - "../../protos/google/cloud/contentwarehouse/v1/ruleset_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/ruleset_service_request.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset_service.proto", - "../../protos/google/cloud/contentwarehouse/v1/synonymset_service_request.proto", - "../../protos/google/cloud/documentai/v1/barcode.proto", - "../../protos/google/cloud/documentai/v1/document.proto", - "../../protos/google/cloud/documentai/v1/geometry.proto" -] diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index e090049671f..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 contentwarehouse = require('@google-cloud/contentwarehouse'); - -function main() { - const documentLinkServiceClient = new contentwarehouse.DocumentLinkServiceClient(); - const documentSchemaServiceClient = new contentwarehouse.DocumentSchemaServiceClient(); - const documentServiceClient = new contentwarehouse.DocumentServiceClient(); - const ruleSetServiceClient = new contentwarehouse.RuleSetServiceClient(); - const synonymSetServiceClient = new contentwarehouse.SynonymSetServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 19092f5daa3..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {DocumentLinkServiceClient, DocumentSchemaServiceClient, DocumentServiceClient, RuleSetServiceClient, SynonymSetServiceClient} from '@google-cloud/contentwarehouse'; - -// check that the client class type name can be used -function doStuffWithDocumentLinkServiceClient(client: DocumentLinkServiceClient) { - client.close(); -} -function doStuffWithDocumentSchemaServiceClient(client: DocumentSchemaServiceClient) { - client.close(); -} -function doStuffWithDocumentServiceClient(client: DocumentServiceClient) { - client.close(); -} -function doStuffWithRuleSetServiceClient(client: RuleSetServiceClient) { - client.close(); -} -function doStuffWithSynonymSetServiceClient(client: SynonymSetServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const documentLinkServiceClient = new DocumentLinkServiceClient(); - doStuffWithDocumentLinkServiceClient(documentLinkServiceClient); - // check that the client instance can be created - const documentSchemaServiceClient = new DocumentSchemaServiceClient(); - doStuffWithDocumentSchemaServiceClient(documentSchemaServiceClient); - // check that the client instance can be created - const documentServiceClient = new DocumentServiceClient(); - doStuffWithDocumentServiceClient(documentServiceClient); - // check that the client instance can be created - const ruleSetServiceClient = new RuleSetServiceClient(); - doStuffWithRuleSetServiceClient(ruleSetServiceClient); - // check that the client instance can be created - const synonymSetServiceClient = new SynonymSetServiceClient(); - doStuffWithSynonymSetServiceClient(synonymSetServiceClient); -} - -main(); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/install.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_link_service_v1.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_link_service_v1.ts deleted file mode 100644 index 18ef476e34b..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_link_service_v1.ts +++ /dev/null @@ -1,1053 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as documentlinkserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.DocumentLinkServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = documentlinkserviceModule.v1.DocumentLinkServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = documentlinkserviceModule.v1.DocumentLinkServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = documentlinkserviceModule.v1.DocumentLinkServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentLinkServiceStub, undefined); - await client.initialize(); - assert(client.documentLinkServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.documentLinkServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentLinkServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - 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 documentlinkserviceModule.v1.DocumentLinkServiceClient({ - 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('listLinkedTargets', () => { - it('invokes listLinkedTargets without error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsResponse() - ); - client.innerApiCalls.listLinkedTargets = stubSimpleCall(expectedResponse); - const [response] = await client.listLinkedTargets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLinkedTargets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLinkedTargets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listLinkedTargets without error using callback', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsResponse() - ); - client.innerApiCalls.listLinkedTargets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listLinkedTargets( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IListLinkedTargetsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLinkedTargets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLinkedTargets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listLinkedTargets with error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listLinkedTargets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listLinkedTargets(request), expectedError); - const actualRequest = (client.innerApiCalls.listLinkedTargets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLinkedTargets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listLinkedTargets with closed client', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.listLinkedTargets(request), expectedError); - }); - }); - - describe('createDocumentLink', () => { - it('invokes createDocumentLink without error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DocumentLink() - ); - client.innerApiCalls.createDocumentLink = stubSimpleCall(expectedResponse); - const [response] = await client.createDocumentLink(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocumentLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocumentLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocumentLink without error using callback', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DocumentLink() - ); - client.innerApiCalls.createDocumentLink = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDocumentLink( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentLink|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocumentLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocumentLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocumentLink with error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocumentLink = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocumentLink(request), expectedError); - const actualRequest = (client.innerApiCalls.createDocumentLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocumentLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocumentLink with closed client', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentLinkRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createDocumentLink(request), expectedError); - }); - }); - - describe('deleteDocumentLink', () => { - it('invokes deleteDocumentLink without error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocumentLink = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocumentLink(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocumentLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocumentLink without error using callback', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocumentLink = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDocumentLink( - 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.deleteDocumentLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocumentLink with error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocumentLink = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocumentLink(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDocumentLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocumentLink with closed client', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentLinkRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteDocumentLink(request), expectedError); - }); - }); - - describe('listLinkedSources', () => { - it('invokes listLinkedSources without error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - ]; - client.innerApiCalls.listLinkedSources = stubSimpleCall(expectedResponse); - const [response] = await client.listLinkedSources(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLinkedSources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLinkedSources as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listLinkedSources without error using callback', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - ]; - client.innerApiCalls.listLinkedSources = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listLinkedSources( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentLink[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listLinkedSources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLinkedSources as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listLinkedSources with error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listLinkedSources = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listLinkedSources(request), expectedError); - const actualRequest = (client.innerApiCalls.listLinkedSources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listLinkedSources as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listLinkedSourcesStream without error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - ]; - client.descriptors.page.listLinkedSources.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listLinkedSourcesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.contentwarehouse.v1.DocumentLink[] = []; - stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.DocumentLink) => { - 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.listLinkedSources.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLinkedSources, request)); - assert( - (client.descriptors.page.listLinkedSources.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listLinkedSourcesStream with error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listLinkedSources.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listLinkedSourcesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.contentwarehouse.v1.DocumentLink[] = []; - stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.DocumentLink) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listLinkedSources.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listLinkedSources, request)); - assert( - (client.descriptors.page.listLinkedSources.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listLinkedSources without error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentLink()), - ]; - client.descriptors.page.listLinkedSources.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.contentwarehouse.v1.IDocumentLink[] = []; - const iterable = client.listLinkedSourcesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listLinkedSources.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLinkedSources.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listLinkedSources with error', async () => { - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListLinkedSourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listLinkedSources.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLinkedSourcesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.contentwarehouse.v1.IDocumentLink[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listLinkedSources.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listLinkedSources.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('documentLink', () => { - const fakePath = "/rendered/path/documentLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document: "documentValue", - document_link: "documentLinkValue", - }; - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.documentLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.documentLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('documentLinkPath', () => { - const result = client.documentLinkPath("projectValue", "locationValue", "documentValue", "documentLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.documentLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDocumentLinkName', () => { - const result = client.matchProjectFromDocumentLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDocumentLinkName', () => { - const result = client.matchLocationFromDocumentLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromDocumentLinkName', () => { - const result = client.matchDocumentFromDocumentLinkName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentLinkFromDocumentLinkName', () => { - const result = client.matchDocumentLinkFromDocumentLinkName(fakePath); - assert.strictEqual(result, "documentLinkValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('documentSchema', () => { - const fakePath = "/rendered/path/documentSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document_schema: "documentSchemaValue", - }; - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.documentSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.documentSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('documentSchemaPath', () => { - const result = client.documentSchemaPath("projectValue", "locationValue", "documentSchemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.documentSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDocumentSchemaName', () => { - const result = client.matchProjectFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDocumentSchemaName', () => { - const result = client.matchLocationFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentSchemaFromDocumentSchemaName', () => { - const result = client.matchDocumentSchemaFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "documentSchemaValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDocument', () => { - const fakePath = "/rendered/path/projectLocationDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document: "documentValue", - }; - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDocumentPath', () => { - const result = client.projectLocationDocumentPath("projectValue", "locationValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDocumentName', () => { - const result = client.matchProjectFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDocumentName', () => { - const result = client.matchLocationFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDocumentsReferenceId', () => { - const fakePath = "/rendered/path/projectLocationDocumentsReferenceId"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - reference_id: "referenceIdValue", - }; - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDocumentsReferenceIdPath', () => { - const result = client.projectLocationDocumentsReferenceIdPath("projectValue", "locationValue", "referenceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchProjectFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchLocationFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceIdFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchReferenceIdFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "referenceIdValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('ruleSet', () => { - const fakePath = "/rendered/path/ruleSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - rule_set: "ruleSetValue", - }; - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.ruleSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ruleSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ruleSetPath', () => { - const result = client.ruleSetPath("projectValue", "locationValue", "ruleSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ruleSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRuleSetName', () => { - const result = client.matchProjectFromRuleSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRuleSetName', () => { - const result = client.matchLocationFromRuleSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRuleSetFromRuleSetName', () => { - const result = client.matchRuleSetFromRuleSetName(fakePath); - assert.strictEqual(result, "ruleSetValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('synonymSet', () => { - const fakePath = "/rendered/path/synonymSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - context: "contextValue", - }; - const client = new documentlinkserviceModule.v1.DocumentLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.synonymSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.synonymSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('synonymSetPath', () => { - const result = client.synonymSetPath("projectValue", "locationValue", "contextValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.synonymSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSynonymSetName', () => { - const result = client.matchProjectFromSynonymSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSynonymSetName', () => { - const result = client.matchLocationFromSynonymSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchContextFromSynonymSetName', () => { - const result = client.matchContextFromSynonymSetName(fakePath); - assert.strictEqual(result, "contextValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_schema_service_v1.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_schema_service_v1.ts deleted file mode 100644 index 8a8effa2119..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_schema_service_v1.ts +++ /dev/null @@ -1,1199 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as documentschemaserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.DocumentSchemaServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = documentschemaserviceModule.v1.DocumentSchemaServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = documentschemaserviceModule.v1.DocumentSchemaServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = documentschemaserviceModule.v1.DocumentSchemaServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentSchemaServiceStub, undefined); - await client.initialize(); - assert(client.documentSchemaServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.documentSchemaServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentSchemaServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - 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 documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - 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('createDocumentSchema', () => { - it('invokes createDocumentSchema without error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DocumentSchema() - ); - client.innerApiCalls.createDocumentSchema = stubSimpleCall(expectedResponse); - const [response] = await client.createDocumentSchema(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocumentSchema without error using callback', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DocumentSchema() - ); - client.innerApiCalls.createDocumentSchema = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDocumentSchema( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentSchema|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocumentSchema with error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocumentSchema = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocumentSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.createDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocumentSchema with closed client', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentSchemaRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createDocumentSchema(request), expectedError); - }); - }); - - describe('updateDocumentSchema', () => { - it('invokes updateDocumentSchema without error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DocumentSchema() - ); - client.innerApiCalls.updateDocumentSchema = stubSimpleCall(expectedResponse); - const [response] = await client.updateDocumentSchema(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocumentSchema without error using callback', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DocumentSchema() - ); - client.innerApiCalls.updateDocumentSchema = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDocumentSchema( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentSchema|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocumentSchema with error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDocumentSchema = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDocumentSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocumentSchema with closed client', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateDocumentSchema(request), expectedError); - }); - }); - - describe('getDocumentSchema', () => { - it('invokes getDocumentSchema without error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DocumentSchema() - ); - client.innerApiCalls.getDocumentSchema = stubSimpleCall(expectedResponse); - const [response] = await client.getDocumentSchema(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocumentSchema without error using callback', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DocumentSchema() - ); - client.innerApiCalls.getDocumentSchema = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDocumentSchema( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentSchema|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocumentSchema with error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDocumentSchema = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDocumentSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.getDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocumentSchema with closed client', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDocumentSchema(request), expectedError); - }); - }); - - describe('deleteDocumentSchema', () => { - it('invokes deleteDocumentSchema without error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocumentSchema = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocumentSchema(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocumentSchema without error using callback', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocumentSchema = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDocumentSchema( - 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.deleteDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocumentSchema with error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocumentSchema = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocumentSchema(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDocumentSchema as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocumentSchema as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocumentSchema with closed client', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentSchemaRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteDocumentSchema(request), expectedError); - }); - }); - - describe('listDocumentSchemas', () => { - it('invokes listDocumentSchemas without error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - ]; - client.innerApiCalls.listDocumentSchemas = stubSimpleCall(expectedResponse); - const [response] = await client.listDocumentSchemas(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDocumentSchemas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocumentSchemas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDocumentSchemas without error using callback', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - ]; - client.innerApiCalls.listDocumentSchemas = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDocumentSchemas( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocumentSchema[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDocumentSchemas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocumentSchemas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDocumentSchemas with error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDocumentSchemas = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDocumentSchemas(request), expectedError); - const actualRequest = (client.innerApiCalls.listDocumentSchemas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDocumentSchemas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDocumentSchemasStream without error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - ]; - client.descriptors.page.listDocumentSchemas.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDocumentSchemasStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.contentwarehouse.v1.DocumentSchema[] = []; - stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.DocumentSchema) => { - 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.listDocumentSchemas.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDocumentSchemas, request)); - assert( - (client.descriptors.page.listDocumentSchemas.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listDocumentSchemasStream with error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDocumentSchemas.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDocumentSchemasStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.contentwarehouse.v1.DocumentSchema[] = []; - stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.DocumentSchema) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDocumentSchemas.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDocumentSchemas, request)); - assert( - (client.descriptors.page.listDocumentSchemas.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDocumentSchemas without error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.DocumentSchema()), - ]; - client.descriptors.page.listDocumentSchemas.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.contentwarehouse.v1.IDocumentSchema[] = []; - const iterable = client.listDocumentSchemasAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDocumentSchemas.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDocumentSchemas.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDocumentSchemas with error', async () => { - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListDocumentSchemasRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listDocumentSchemas.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDocumentSchemasAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.contentwarehouse.v1.IDocumentSchema[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDocumentSchemas.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDocumentSchemas.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('documentLink', () => { - const fakePath = "/rendered/path/documentLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document: "documentValue", - document_link: "documentLinkValue", - }; - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.documentLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.documentLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('documentLinkPath', () => { - const result = client.documentLinkPath("projectValue", "locationValue", "documentValue", "documentLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.documentLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDocumentLinkName', () => { - const result = client.matchProjectFromDocumentLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDocumentLinkName', () => { - const result = client.matchLocationFromDocumentLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromDocumentLinkName', () => { - const result = client.matchDocumentFromDocumentLinkName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentLinkFromDocumentLinkName', () => { - const result = client.matchDocumentLinkFromDocumentLinkName(fakePath); - assert.strictEqual(result, "documentLinkValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('documentSchema', () => { - const fakePath = "/rendered/path/documentSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document_schema: "documentSchemaValue", - }; - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.documentSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.documentSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('documentSchemaPath', () => { - const result = client.documentSchemaPath("projectValue", "locationValue", "documentSchemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.documentSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDocumentSchemaName', () => { - const result = client.matchProjectFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDocumentSchemaName', () => { - const result = client.matchLocationFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentSchemaFromDocumentSchemaName', () => { - const result = client.matchDocumentSchemaFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "documentSchemaValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - 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('projectLocationDocument', () => { - const fakePath = "/rendered/path/projectLocationDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document: "documentValue", - }; - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDocumentPath', () => { - const result = client.projectLocationDocumentPath("projectValue", "locationValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDocumentName', () => { - const result = client.matchProjectFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDocumentName', () => { - const result = client.matchLocationFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDocumentsReferenceId', () => { - const fakePath = "/rendered/path/projectLocationDocumentsReferenceId"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - reference_id: "referenceIdValue", - }; - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDocumentsReferenceIdPath', () => { - const result = client.projectLocationDocumentsReferenceIdPath("projectValue", "locationValue", "referenceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchProjectFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchLocationFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceIdFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchReferenceIdFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "referenceIdValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('ruleSet', () => { - const fakePath = "/rendered/path/ruleSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - rule_set: "ruleSetValue", - }; - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.ruleSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ruleSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ruleSetPath', () => { - const result = client.ruleSetPath("projectValue", "locationValue", "ruleSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ruleSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRuleSetName', () => { - const result = client.matchProjectFromRuleSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRuleSetName', () => { - const result = client.matchLocationFromRuleSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRuleSetFromRuleSetName', () => { - const result = client.matchRuleSetFromRuleSetName(fakePath); - assert.strictEqual(result, "ruleSetValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('synonymSet', () => { - const fakePath = "/rendered/path/synonymSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - context: "contextValue", - }; - const client = new documentschemaserviceModule.v1.DocumentSchemaServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.synonymSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.synonymSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('synonymSetPath', () => { - const result = client.synonymSetPath("projectValue", "locationValue", "contextValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.synonymSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSynonymSetName', () => { - const result = client.matchProjectFromSynonymSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSynonymSetName', () => { - const result = client.matchLocationFromSynonymSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchContextFromSynonymSetName', () => { - const result = client.matchContextFromSynonymSetName(fakePath); - assert.strictEqual(result, "contextValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_service_v1.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_service_v1.ts deleted file mode 100644 index fb6f457b40f..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_document_service_v1.ts +++ /dev/null @@ -1,1377 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as documentserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.DocumentServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = documentserviceModule.v1.DocumentServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = documentserviceModule.v1.DocumentServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = documentserviceModule.v1.DocumentServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new documentserviceModule.v1.DocumentServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentServiceStub, undefined); - await client.initialize(); - assert(client.documentServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.documentServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentserviceModule.v1.DocumentServiceClient({ - 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 documentserviceModule.v1.DocumentServiceClient({ - 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('createDocument', () => { - it('invokes createDocument without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentResponse() - ); - client.innerApiCalls.createDocument = stubSimpleCall(expectedResponse); - const [response] = await client.createDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocument without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentResponse() - ); - client.innerApiCalls.createDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDocument( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ICreateDocumentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocument with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDocument with closed client', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createDocument(request), expectedError); - }); - }); - - describe('getDocument', () => { - it('invokes getDocument without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.Document() - ); - client.innerApiCalls.getDocument = stubSimpleCall(expectedResponse); - const [response] = await client.getDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocument without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.Document() - ); - client.innerApiCalls.getDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDocument( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocument with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDocument with closed client', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDocument(request), expectedError); - }); - }); - - describe('updateDocument', () => { - it('invokes updateDocument without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateDocumentResponse() - ); - client.innerApiCalls.updateDocument = stubSimpleCall(expectedResponse); - const [response] = await client.updateDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocument without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateDocumentResponse() - ); - client.innerApiCalls.updateDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDocument( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IUpdateDocumentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocument with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateDocument with closed client', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateDocument(request), expectedError); - }); - }); - - describe('deleteDocument', () => { - it('invokes deleteDocument without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocument = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDocument(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocument without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDocument( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocument with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteDocument with closed client', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteDocumentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteDocumentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteDocument(request), expectedError); - }); - }); - - describe('fetchAcl', () => { - it('invokes fetchAcl without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.FetchAclRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.FetchAclRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.FetchAclResponse() - ); - client.innerApiCalls.fetchAcl = stubSimpleCall(expectedResponse); - const [response] = await client.fetchAcl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.fetchAcl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchAcl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchAcl without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.FetchAclRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.FetchAclRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.FetchAclResponse() - ); - client.innerApiCalls.fetchAcl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.fetchAcl( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IFetchAclResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.fetchAcl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchAcl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchAcl with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.FetchAclRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.FetchAclRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.fetchAcl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchAcl(request), expectedError); - const actualRequest = (client.innerApiCalls.fetchAcl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchAcl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchAcl with closed client', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.FetchAclRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.FetchAclRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.fetchAcl(request), expectedError); - }); - }); - - describe('setAcl', () => { - it('invokes setAcl without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SetAclRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SetAclRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SetAclResponse() - ); - client.innerApiCalls.setAcl = stubSimpleCall(expectedResponse); - const [response] = await client.setAcl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setAcl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setAcl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setAcl without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SetAclRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SetAclRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SetAclResponse() - ); - client.innerApiCalls.setAcl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setAcl( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ISetAclResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setAcl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setAcl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setAcl with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SetAclRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SetAclRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setAcl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setAcl(request), expectedError); - const actualRequest = (client.innerApiCalls.setAcl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setAcl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setAcl with closed client', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SetAclRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SetAclRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setAcl(request), expectedError); - }); - }); - - describe('searchDocuments', () => { - it('invokes searchDocuments without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - ]; - client.innerApiCalls.searchDocuments = stubSimpleCall(expectedResponse); - const [response] = await client.searchDocuments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchDocuments without error using callback', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - ]; - client.innerApiCalls.searchDocuments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchDocuments( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchDocuments with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchDocuments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.searchDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes searchDocumentsStream without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - ]; - client.descriptors.page.searchDocuments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchDocumentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument[] = []; - stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument) => { - 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.searchDocuments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchDocuments, request)); - assert( - (client.descriptors.page.searchDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes searchDocumentsStream with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.searchDocuments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchDocumentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument[] = []; - stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchDocuments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchDocuments, request)); - assert( - (client.descriptors.page.searchDocuments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchDocuments without error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.MatchingDocument()), - ]; - client.descriptors.page.searchDocuments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument[] = []; - const iterable = client.searchDocumentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchDocuments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchDocuments with error', async () => { - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SearchDocumentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.SearchDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.searchDocuments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchDocumentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.contentwarehouse.v1.SearchDocumentsResponse.IMatchingDocument[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchDocuments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchDocuments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('documentLink', () => { - const fakePath = "/rendered/path/documentLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document: "documentValue", - document_link: "documentLinkValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.documentLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.documentLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('documentLinkPath', () => { - const result = client.documentLinkPath("projectValue", "locationValue", "documentValue", "documentLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.documentLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDocumentLinkName', () => { - const result = client.matchProjectFromDocumentLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDocumentLinkName', () => { - const result = client.matchLocationFromDocumentLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromDocumentLinkName', () => { - const result = client.matchDocumentFromDocumentLinkName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentLinkFromDocumentLinkName', () => { - const result = client.matchDocumentLinkFromDocumentLinkName(fakePath); - assert.strictEqual(result, "documentLinkValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('documentSchema', () => { - const fakePath = "/rendered/path/documentSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document_schema: "documentSchemaValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.documentSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.documentSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('documentSchemaPath', () => { - const result = client.documentSchemaPath("projectValue", "locationValue", "documentSchemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.documentSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDocumentSchemaName', () => { - const result = client.matchProjectFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDocumentSchemaName', () => { - const result = client.matchLocationFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentSchemaFromDocumentSchemaName', () => { - const result = client.matchDocumentSchemaFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "documentSchemaValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDocument', () => { - const fakePath = "/rendered/path/projectLocationDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document: "documentValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDocumentPath', () => { - const result = client.projectLocationDocumentPath("projectValue", "locationValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDocumentName', () => { - const result = client.matchProjectFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDocumentName', () => { - const result = client.matchLocationFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDocumentsReferenceId', () => { - const fakePath = "/rendered/path/projectLocationDocumentsReferenceId"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - reference_id: "referenceIdValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDocumentsReferenceIdPath', () => { - const result = client.projectLocationDocumentsReferenceIdPath("projectValue", "locationValue", "referenceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchProjectFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchLocationFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceIdFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchReferenceIdFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "referenceIdValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('ruleSet', () => { - const fakePath = "/rendered/path/ruleSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - rule_set: "ruleSetValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.ruleSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ruleSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ruleSetPath', () => { - const result = client.ruleSetPath("projectValue", "locationValue", "ruleSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ruleSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRuleSetName', () => { - const result = client.matchProjectFromRuleSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRuleSetName', () => { - const result = client.matchLocationFromRuleSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRuleSetFromRuleSetName', () => { - const result = client.matchRuleSetFromRuleSetName(fakePath); - assert.strictEqual(result, "ruleSetValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('synonymSet', () => { - const fakePath = "/rendered/path/synonymSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - context: "contextValue", - }; - const client = new documentserviceModule.v1.DocumentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.synonymSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.synonymSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('synonymSetPath', () => { - const result = client.synonymSetPath("projectValue", "locationValue", "contextValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.synonymSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSynonymSetName', () => { - const result = client.matchProjectFromSynonymSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSynonymSetName', () => { - const result = client.matchLocationFromSynonymSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchContextFromSynonymSetName', () => { - const result = client.matchContextFromSynonymSetName(fakePath); - assert.strictEqual(result, "contextValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_rule_set_service_v1.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_rule_set_service_v1.ts deleted file mode 100644 index 695a84b8fad..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_rule_set_service_v1.ts +++ /dev/null @@ -1,1161 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as rulesetserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.RuleSetServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = rulesetserviceModule.v1.RuleSetServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = rulesetserviceModule.v1.RuleSetServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = rulesetserviceModule.v1.RuleSetServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.ruleSetServiceStub, undefined); - await client.initialize(); - assert(client.ruleSetServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.ruleSetServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.ruleSetServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - 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 rulesetserviceModule.v1.RuleSetServiceClient({ - 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('createRuleSet', () => { - it('invokes createRuleSet without error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateRuleSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.RuleSet() - ); - client.innerApiCalls.createRuleSet = stubSimpleCall(expectedResponse); - const [response] = await client.createRuleSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createRuleSet without error using callback', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateRuleSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.RuleSet() - ); - client.innerApiCalls.createRuleSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createRuleSet( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IRuleSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createRuleSet with error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateRuleSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createRuleSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createRuleSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createRuleSet with closed client', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateRuleSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createRuleSet(request), expectedError); - }); - }); - - describe('getRuleSet', () => { - it('invokes getRuleSet without error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.RuleSet() - ); - client.innerApiCalls.getRuleSet = stubSimpleCall(expectedResponse); - const [response] = await client.getRuleSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuleSet without error using callback', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.RuleSet() - ); - client.innerApiCalls.getRuleSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRuleSet( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IRuleSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuleSet with error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRuleSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRuleSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRuleSet with closed client', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getRuleSet(request), expectedError); - }); - }); - - describe('updateRuleSet', () => { - it('invokes updateRuleSet without error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.RuleSet() - ); - client.innerApiCalls.updateRuleSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateRuleSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRuleSet without error using callback', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.RuleSet() - ); - client.innerApiCalls.updateRuleSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateRuleSet( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IRuleSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRuleSet with error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateRuleSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateRuleSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updateRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateRuleSet with closed client', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateRuleSet(request), expectedError); - }); - }); - - describe('deleteRuleSet', () => { - it('invokes deleteRuleSet without error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteRuleSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteRuleSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRuleSet without error using callback', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteRuleSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteRuleSet( - 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.deleteRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRuleSet with error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRuleSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteRuleSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteRuleSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRuleSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteRuleSet with closed client', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteRuleSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteRuleSet(request), expectedError); - }); - }); - - describe('listRuleSets', () => { - it('invokes listRuleSets without error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - ]; - client.innerApiCalls.listRuleSets = stubSimpleCall(expectedResponse); - const [response] = await client.listRuleSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRuleSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuleSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuleSets without error using callback', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - ]; - client.innerApiCalls.listRuleSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRuleSets( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.IRuleSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRuleSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuleSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuleSets with error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRuleSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRuleSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listRuleSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRuleSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRuleSetsStream without error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - ]; - client.descriptors.page.listRuleSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRuleSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.contentwarehouse.v1.RuleSet[] = []; - stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.RuleSet) => { - 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.listRuleSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRuleSets, request)); - assert( - (client.descriptors.page.listRuleSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listRuleSetsStream with error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRuleSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRuleSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.contentwarehouse.v1.RuleSet[] = []; - stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.RuleSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRuleSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRuleSets, request)); - assert( - (client.descriptors.page.listRuleSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRuleSets without error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.RuleSet()), - ]; - client.descriptors.page.listRuleSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.contentwarehouse.v1.IRuleSet[] = []; - const iterable = client.listRuleSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRuleSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRuleSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRuleSets with error', async () => { - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListRuleSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListRuleSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listRuleSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRuleSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.contentwarehouse.v1.IRuleSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRuleSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRuleSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('documentLink', () => { - const fakePath = "/rendered/path/documentLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document: "documentValue", - document_link: "documentLinkValue", - }; - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.documentLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.documentLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('documentLinkPath', () => { - const result = client.documentLinkPath("projectValue", "locationValue", "documentValue", "documentLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.documentLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDocumentLinkName', () => { - const result = client.matchProjectFromDocumentLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDocumentLinkName', () => { - const result = client.matchLocationFromDocumentLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromDocumentLinkName', () => { - const result = client.matchDocumentFromDocumentLinkName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentLinkFromDocumentLinkName', () => { - const result = client.matchDocumentLinkFromDocumentLinkName(fakePath); - assert.strictEqual(result, "documentLinkValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('documentSchema', () => { - const fakePath = "/rendered/path/documentSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document_schema: "documentSchemaValue", - }; - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.documentSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.documentSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('documentSchemaPath', () => { - const result = client.documentSchemaPath("projectValue", "locationValue", "documentSchemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.documentSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDocumentSchemaName', () => { - const result = client.matchProjectFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDocumentSchemaName', () => { - const result = client.matchLocationFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentSchemaFromDocumentSchemaName', () => { - const result = client.matchDocumentSchemaFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "documentSchemaValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDocument', () => { - const fakePath = "/rendered/path/projectLocationDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document: "documentValue", - }; - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDocumentPath', () => { - const result = client.projectLocationDocumentPath("projectValue", "locationValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDocumentName', () => { - const result = client.matchProjectFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDocumentName', () => { - const result = client.matchLocationFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDocumentsReferenceId', () => { - const fakePath = "/rendered/path/projectLocationDocumentsReferenceId"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - reference_id: "referenceIdValue", - }; - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDocumentsReferenceIdPath', () => { - const result = client.projectLocationDocumentsReferenceIdPath("projectValue", "locationValue", "referenceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchProjectFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchLocationFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceIdFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchReferenceIdFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "referenceIdValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('ruleSet', () => { - const fakePath = "/rendered/path/ruleSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - rule_set: "ruleSetValue", - }; - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.ruleSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ruleSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ruleSetPath', () => { - const result = client.ruleSetPath("projectValue", "locationValue", "ruleSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ruleSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRuleSetName', () => { - const result = client.matchProjectFromRuleSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRuleSetName', () => { - const result = client.matchLocationFromRuleSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRuleSetFromRuleSetName', () => { - const result = client.matchRuleSetFromRuleSetName(fakePath); - assert.strictEqual(result, "ruleSetValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('synonymSet', () => { - const fakePath = "/rendered/path/synonymSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - context: "contextValue", - }; - const client = new rulesetserviceModule.v1.RuleSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.synonymSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.synonymSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('synonymSetPath', () => { - const result = client.synonymSetPath("projectValue", "locationValue", "contextValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.synonymSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSynonymSetName', () => { - const result = client.matchProjectFromSynonymSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSynonymSetName', () => { - const result = client.matchLocationFromSynonymSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchContextFromSynonymSetName', () => { - const result = client.matchContextFromSynonymSetName(fakePath); - assert.strictEqual(result, "contextValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_synonym_set_service_v1.ts b/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_synonym_set_service_v1.ts deleted file mode 100644 index bde80381fe7..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/test/gapic_synonym_set_service_v1.ts +++ /dev/null @@ -1,1161 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as synonymsetserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.SynonymSetServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = synonymsetserviceModule.v1.SynonymSetServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = synonymsetserviceModule.v1.SynonymSetServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = synonymsetserviceModule.v1.SynonymSetServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.synonymSetServiceStub, undefined); - await client.initialize(); - assert(client.synonymSetServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.synonymSetServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.synonymSetServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - 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 synonymsetserviceModule.v1.SynonymSetServiceClient({ - 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('createSynonymSet', () => { - it('invokes createSynonymSet without error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SynonymSet() - ); - client.innerApiCalls.createSynonymSet = stubSimpleCall(expectedResponse); - const [response] = await client.createSynonymSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSynonymSet without error using callback', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SynonymSet() - ); - client.innerApiCalls.createSynonymSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSynonymSet( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ISynonymSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSynonymSet with error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSynonymSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createSynonymSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createSynonymSet with closed client', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.CreateSynonymSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createSynonymSet(request), expectedError); - }); - }); - - describe('getSynonymSet', () => { - it('invokes getSynonymSet without error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SynonymSet() - ); - client.innerApiCalls.getSynonymSet = stubSimpleCall(expectedResponse); - const [response] = await client.getSynonymSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSynonymSet without error using callback', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SynonymSet() - ); - client.innerApiCalls.getSynonymSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSynonymSet( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ISynonymSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSynonymSet with error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSynonymSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSynonymSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getSynonymSet with closed client', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.GetSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.GetSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getSynonymSet(request), expectedError); - }); - }); - - describe('updateSynonymSet', () => { - it('invokes updateSynonymSet without error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SynonymSet() - ); - client.innerApiCalls.updateSynonymSet = stubSimpleCall(expectedResponse); - const [response] = await client.updateSynonymSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSynonymSet without error using callback', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.SynonymSet() - ); - client.innerApiCalls.updateSynonymSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateSynonymSet( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ISynonymSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSynonymSet with error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSynonymSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateSynonymSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updateSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateSynonymSet with closed client', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.UpdateSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateSynonymSet(request), expectedError); - }); - }); - - describe('deleteSynonymSet', () => { - it('invokes deleteSynonymSet without error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSynonymSet = stubSimpleCall(expectedResponse); - const [response] = await client.deleteSynonymSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSynonymSet without error using callback', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSynonymSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSynonymSet( - 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.deleteSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSynonymSet with error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSynonymSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteSynonymSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSynonymSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSynonymSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteSynonymSet with closed client', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.DeleteSynonymSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteSynonymSet(request), expectedError); - }); - }); - - describe('listSynonymSets', () => { - it('invokes listSynonymSets without error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - ]; - client.innerApiCalls.listSynonymSets = stubSimpleCall(expectedResponse); - const [response] = await client.listSynonymSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSynonymSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSynonymSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSynonymSets without error using callback', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - ]; - client.innerApiCalls.listSynonymSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSynonymSets( - request, - (err?: Error|null, result?: protos.google.cloud.contentwarehouse.v1.ISynonymSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSynonymSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSynonymSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSynonymSets with error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSynonymSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSynonymSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listSynonymSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSynonymSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSynonymSetsStream without error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - ]; - client.descriptors.page.listSynonymSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSynonymSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.contentwarehouse.v1.SynonymSet[] = []; - stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.SynonymSet) => { - 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.listSynonymSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSynonymSets, request)); - assert( - (client.descriptors.page.listSynonymSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listSynonymSetsStream with error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSynonymSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSynonymSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.contentwarehouse.v1.SynonymSet[] = []; - stream.on('data', (response: protos.google.cloud.contentwarehouse.v1.SynonymSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSynonymSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSynonymSets, request)); - assert( - (client.descriptors.page.listSynonymSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSynonymSets without error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - generateSampleMessage(new protos.google.cloud.contentwarehouse.v1.SynonymSet()), - ]; - client.descriptors.page.listSynonymSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.contentwarehouse.v1.ISynonymSet[] = []; - const iterable = client.listSynonymSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSynonymSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSynonymSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSynonymSets with error', async () => { - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.contentwarehouse.v1.ListSynonymSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listSynonymSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSynonymSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.contentwarehouse.v1.ISynonymSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSynonymSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSynonymSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('documentLink', () => { - const fakePath = "/rendered/path/documentLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document: "documentValue", - document_link: "documentLinkValue", - }; - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.documentLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.documentLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('documentLinkPath', () => { - const result = client.documentLinkPath("projectValue", "locationValue", "documentValue", "documentLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.documentLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDocumentLinkName', () => { - const result = client.matchProjectFromDocumentLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDocumentLinkName', () => { - const result = client.matchLocationFromDocumentLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromDocumentLinkName', () => { - const result = client.matchDocumentFromDocumentLinkName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentLinkFromDocumentLinkName', () => { - const result = client.matchDocumentLinkFromDocumentLinkName(fakePath); - assert.strictEqual(result, "documentLinkValue"); - assert((client.pathTemplates.documentLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('documentSchema', () => { - const fakePath = "/rendered/path/documentSchema"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document_schema: "documentSchemaValue", - }; - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.documentSchemaPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.documentSchemaPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('documentSchemaPath', () => { - const result = client.documentSchemaPath("projectValue", "locationValue", "documentSchemaValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.documentSchemaPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDocumentSchemaName', () => { - const result = client.matchProjectFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDocumentSchemaName', () => { - const result = client.matchLocationFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentSchemaFromDocumentSchemaName', () => { - const result = client.matchDocumentSchemaFromDocumentSchemaName(fakePath); - assert.strictEqual(result, "documentSchemaValue"); - assert((client.pathTemplates.documentSchemaPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDocument', () => { - const fakePath = "/rendered/path/projectLocationDocument"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - document: "documentValue", - }; - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDocumentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDocumentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDocumentPath', () => { - const result = client.projectLocationDocumentPath("projectValue", "locationValue", "documentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDocumentName', () => { - const result = client.matchProjectFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDocumentName', () => { - const result = client.matchLocationFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDocumentFromProjectLocationDocumentName', () => { - const result = client.matchDocumentFromProjectLocationDocumentName(fakePath); - assert.strictEqual(result, "documentValue"); - assert((client.pathTemplates.projectLocationDocumentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationDocumentsReferenceId', () => { - const fakePath = "/rendered/path/projectLocationDocumentsReferenceId"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - reference_id: "referenceIdValue", - }; - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationDocumentsReferenceIdPath', () => { - const result = client.projectLocationDocumentsReferenceIdPath("projectValue", "locationValue", "referenceIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchProjectFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchLocationFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReferenceIdFromProjectLocationDocumentsReferenceIdName', () => { - const result = client.matchReferenceIdFromProjectLocationDocumentsReferenceIdName(fakePath); - assert.strictEqual(result, "referenceIdValue"); - assert((client.pathTemplates.projectLocationDocumentsReferenceIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('ruleSet', () => { - const fakePath = "/rendered/path/ruleSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - rule_set: "ruleSetValue", - }; - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.ruleSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ruleSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ruleSetPath', () => { - const result = client.ruleSetPath("projectValue", "locationValue", "ruleSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ruleSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRuleSetName', () => { - const result = client.matchProjectFromRuleSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRuleSetName', () => { - const result = client.matchLocationFromRuleSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRuleSetFromRuleSetName', () => { - const result = client.matchRuleSetFromRuleSetName(fakePath); - assert.strictEqual(result, "ruleSetValue"); - assert((client.pathTemplates.ruleSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('synonymSet', () => { - const fakePath = "/rendered/path/synonymSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - context: "contextValue", - }; - const client = new synonymsetserviceModule.v1.SynonymSetServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.synonymSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.synonymSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('synonymSetPath', () => { - const result = client.synonymSetPath("projectValue", "locationValue", "contextValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.synonymSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSynonymSetName', () => { - const result = client.matchProjectFromSynonymSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSynonymSetName', () => { - const result = client.matchLocationFromSynonymSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchContextFromSynonymSetName', () => { - const result = client.matchContextFromSynonymSetName(fakePath); - assert.strictEqual(result, "contextValue"); - assert((client.pathTemplates.synonymSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/tsconfig.json b/owl-bot-staging/google-cloud-contentwarehouse/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-contentwarehouse/v1/webpack.config.js b/owl-bot-staging/google-cloud-contentwarehouse/v1/webpack.config.js deleted file mode 100644 index aa25d4769e1..00000000000 --- a/owl-bot-staging/google-cloud-contentwarehouse/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'DocumentLinkService', - filename: './document-link-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/packages/google-cloud-contentwarehouse/protos/google/cloud/documentai/v1/document_io.proto b/packages/google-cloud-contentwarehouse/protos/google/cloud/documentai/v1/document_io.proto index 3240d494e8f..d56086336d2 100644 --- a/packages/google-cloud-contentwarehouse/protos/google/cloud/documentai/v1/document_io.proto +++ b/packages/google-cloud-contentwarehouse/protos/google/cloud/documentai/v1/document_io.proto @@ -74,6 +74,15 @@ message BatchDocumentsInputConfig { message DocumentOutputConfig { // The configuration used when outputting documents. message GcsOutputConfig { + // The sharding config for the output document. + message ShardingConfig { + // The number of pages per shard. + int32 pages_per_shard = 1; + + // The number of overlapping pages between consecutive shards. + int32 pages_overlap = 2; + } + // The Cloud Storage uri (a directory) of the output. string gcs_uri = 1; @@ -81,6 +90,9 @@ message DocumentOutputConfig { // Only supports top level document and pages field so it must be in the // form of `{document_field_name}` or `pages.{page_field_name}`. google.protobuf.FieldMask field_mask = 2; + + // Specifies the sharding config for the output document. + ShardingConfig sharding_config = 3; } // The destination of the results.