From 255e67b7f4b49c815126102d6a694ae5b6abbc3c Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 11 Aug 2021 22:47:22 +0000 Subject: [PATCH 1/3] fix: Update DocumentUnderstandingService default_host in v1beta2 from a regional endpoint, to non-regional Committer: @nicain PiperOrigin-RevId: 390219495 Source-Link: https://github.com/googleapis/googleapis/commit/09a61830286f02b7cc3c203cf99cd8d7039504b1 Source-Link: https://github.com/googleapis/googleapis-gen/commit/6a6d8a449edb378a9d352716cafea8af5e5756f0 --- owl-bot-staging/v1/.eslintignore | 6 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 10 + owl-bot-staging/v1/package.json | 64 + .../google/cloud/documentai/v1/document.proto | 730 ++++++++ .../cloud/documentai/v1/document_io.proto | 86 + .../v1/document_processor_service.proto | 301 ++++ .../google/cloud/documentai/v1/geometry.proto | 57 + .../documentai/v1/operation_metadata.proto | 64 + owl-bot-staging/v1/src/index.ts | 25 + .../v1/document_processor_service_client.ts | 721 ++++++++ ...ument_processor_service_client_config.json | 41 + ...document_processor_service_proto_list.json | 7 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 53 + owl-bot-staging/v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + owl-bot-staging/v1/system-test/install.ts | 49 + .../gapic_document_processor_service_v1.ts | 603 +++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + owl-bot-staging/v1beta1/.eslintignore | 6 + owl-bot-staging/v1beta1/.eslintrc.json | 3 + owl-bot-staging/v1beta1/.gitignore | 14 + owl-bot-staging/v1beta1/.jsdoc.js | 55 + owl-bot-staging/v1beta1/.mocharc.js | 33 + owl-bot-staging/v1beta1/.prettierrc.js | 22 + owl-bot-staging/v1beta1/README.md | 1 + .../v1beta1/linkinator.config.json | 10 + owl-bot-staging/v1beta1/package.json | 64 + .../cloud/documentai/v1beta1/document.proto | 449 +++++ .../v1beta1/document_understanding.proto | 302 ++++ .../cloud/documentai/v1beta1/geometry.proto | 58 + owl-bot-staging/v1beta1/src/index.ts | 25 + .../document_understanding_service_client.ts | 415 +++++ ...t_understanding_service_client_config.json | 31 + ...ment_understanding_service_proto_list.json | 5 + .../v1beta1/src/v1beta1/gapic_metadata.json | 33 + owl-bot-staging/v1beta1/src/v1beta1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta1/system-test/install.ts | 49 + ..._document_understanding_service_v1beta1.ts | 276 +++ owl-bot-staging/v1beta1/tsconfig.json | 19 + owl-bot-staging/v1beta1/webpack.config.js | 64 + owl-bot-staging/v1beta2/.eslintignore | 6 + owl-bot-staging/v1beta2/.eslintrc.json | 3 + owl-bot-staging/v1beta2/.gitignore | 14 + owl-bot-staging/v1beta2/.jsdoc.js | 55 + owl-bot-staging/v1beta2/.mocharc.js | 33 + owl-bot-staging/v1beta2/.prettierrc.js | 22 + owl-bot-staging/v1beta2/README.md | 1 + .../v1beta2/linkinator.config.json | 10 + owl-bot-staging/v1beta2/package.json | 64 + .../cloud/documentai/v1beta2/document.proto | 519 ++++++ .../v1beta2/document_understanding.proto | 346 ++++ .../cloud/documentai/v1beta2/geometry.proto | 57 + owl-bot-staging/v1beta2/src/index.ts | 25 + .../document_understanding_service_client.ts | 516 ++++++ ...t_understanding_service_client_config.json | 36 + ...ment_understanding_service_proto_list.json | 5 + .../v1beta2/src/v1beta2/gapic_metadata.json | 43 + owl-bot-staging/v1beta2/src/v1beta2/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta2/system-test/install.ts | 49 + ..._document_understanding_service_v1beta2.ts | 364 ++++ owl-bot-staging/v1beta2/tsconfig.json | 19 + owl-bot-staging/v1beta2/webpack.config.js | 64 + owl-bot-staging/v1beta3/.eslintignore | 6 + owl-bot-staging/v1beta3/.eslintrc.json | 3 + owl-bot-staging/v1beta3/.gitignore | 14 + owl-bot-staging/v1beta3/.jsdoc.js | 55 + owl-bot-staging/v1beta3/.mocharc.js | 33 + owl-bot-staging/v1beta3/.prettierrc.js | 22 + owl-bot-staging/v1beta3/README.md | 1 + .../v1beta3/linkinator.config.json | 10 + owl-bot-staging/v1beta3/package.json | 64 + .../cloud/documentai/v1beta3/document.proto | 730 ++++++++ .../documentai/v1beta3/document_io.proto | 86 + .../v1beta3/document_processor_service.proto | 572 ++++++ .../cloud/documentai/v1beta3/geometry.proto | 57 + .../v1beta3/operation_metadata.proto | 64 + .../cloud/documentai/v1beta3/processor.proto | 99 + .../documentai/v1beta3/processor_type.proto | 60 + owl-bot-staging/v1beta3/src/index.ts | 25 + .../document_processor_service_client.ts | 1502 ++++++++++++++++ ...ument_processor_service_client_config.json | 65 + ...document_processor_service_proto_list.json | 9 + .../v1beta3/src/v1beta3/gapic_metadata.json | 117 ++ owl-bot-staging/v1beta3/src/v1beta3/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1beta3/system-test/install.ts | 49 + ...apic_document_processor_service_v1beta3.ts | 1587 +++++++++++++++++ owl-bot-staging/v1beta3/tsconfig.json | 19 + owl-bot-staging/v1beta3/webpack.config.js | 64 + 102 files changed, 12838 insertions(+) create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/cloud/documentai/v1/document.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_io.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_processor_service.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/documentai/v1/geometry.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/documentai/v1/operation_metadata.proto create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/document_processor_service_client.ts create mode 100644 owl-bot-staging/v1/src/v1/document_processor_service_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/document_processor_service_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_document_processor_service_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js create mode 100644 owl-bot-staging/v1beta1/.eslintignore create mode 100644 owl-bot-staging/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/v1beta1/.gitignore create mode 100644 owl-bot-staging/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/v1beta1/README.md create mode 100644 owl-bot-staging/v1beta1/linkinator.config.json create mode 100644 owl-bot-staging/v1beta1/package.json create mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto create mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto create mode 100644 owl-bot-staging/v1beta1/src/index.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client.ts create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client_config.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_proto_list.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/v1beta1/test/gapic_document_understanding_service_v1beta1.ts create mode 100644 owl-bot-staging/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/v1beta1/webpack.config.js create mode 100644 owl-bot-staging/v1beta2/.eslintignore create mode 100644 owl-bot-staging/v1beta2/.eslintrc.json create mode 100644 owl-bot-staging/v1beta2/.gitignore create mode 100644 owl-bot-staging/v1beta2/.jsdoc.js create mode 100644 owl-bot-staging/v1beta2/.mocharc.js create mode 100644 owl-bot-staging/v1beta2/.prettierrc.js create mode 100644 owl-bot-staging/v1beta2/README.md create mode 100644 owl-bot-staging/v1beta2/linkinator.config.json create mode 100644 owl-bot-staging/v1beta2/package.json create mode 100644 owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto create mode 100644 owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto create mode 100644 owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto create mode 100644 owl-bot-staging/v1beta2/src/index.ts create mode 100644 owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client.ts create mode 100644 owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client_config.json create mode 100644 owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_proto_list.json create mode 100644 owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta2/src/v1beta2/index.ts create mode 100644 owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1beta2/system-test/install.ts create mode 100644 owl-bot-staging/v1beta2/test/gapic_document_understanding_service_v1beta2.ts create mode 100644 owl-bot-staging/v1beta2/tsconfig.json create mode 100644 owl-bot-staging/v1beta2/webpack.config.js create mode 100644 owl-bot-staging/v1beta3/.eslintignore create mode 100644 owl-bot-staging/v1beta3/.eslintrc.json create mode 100644 owl-bot-staging/v1beta3/.gitignore create mode 100644 owl-bot-staging/v1beta3/.jsdoc.js create mode 100644 owl-bot-staging/v1beta3/.mocharc.js create mode 100644 owl-bot-staging/v1beta3/.prettierrc.js create mode 100644 owl-bot-staging/v1beta3/README.md create mode 100644 owl-bot-staging/v1beta3/linkinator.config.json create mode 100644 owl-bot-staging/v1beta3/package.json create mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto create mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto create mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto create mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto create mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto create mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto create mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto create mode 100644 owl-bot-staging/v1beta3/src/index.ts create mode 100644 owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client.ts create mode 100644 owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client_config.json create mode 100644 owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_proto_list.json create mode 100644 owl-bot-staging/v1beta3/src/v1beta3/gapic_metadata.json create mode 100644 owl-bot-staging/v1beta3/src/v1beta3/index.ts create mode 100644 owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1beta3/system-test/install.ts create mode 100644 owl-bot-staging/v1beta3/test/gapic_document_processor_service_v1beta3.ts create mode 100644 owl-bot-staging/v1beta3/tsconfig.json create mode 100644 owl-bot-staging/v1beta3/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 000000000..521dc25a2 --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,6 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 000000000..a00b08ce2 --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// 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. +// +// ** This file 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 2021 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/documentai', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 000000000..50bc7f792 --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 000000000..84f4713a0 --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 000000000..f41eef852 --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Documentai: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 000000000..29a223b6d --- /dev/null +++ b/owl-bot-staging/v1/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 000000000..57616ace7 --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/documentai", + "version": "0.1.0", + "description": "Documentai client for Node.js", + "repository": "googleapis/nodejs-documentai", + "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 documentai", + "documentai", + "document processor service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.19.0" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@types/node": "^14.17.3", + "@types/sinon": "^10.0.2", + "c8": "^7.7.3", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.0", + "jsdoc-region-tag": "^1.1.0", + "linkinator": "^2.13.6", + "mocha": "^9.0.2", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.1", + "ts-loader": "^9.2.3", + "typescript": "^4.3.4", + "webpack": "^5.39.1", + "webpack-cli": "^4.7.2" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document.proto b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document.proto new file mode 100644 index 000000000..467a44921 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document.proto @@ -0,0 +1,730 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +import "google/api/field_behavior.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"; +import "google/api/annotations.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 Understanding +// AI. +// It is an interchange format that provides insights into documents and allows +// for collaboration between users and Document Understanding 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; + } + + // 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; + } + + // 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; + } + + // 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; + } + + // 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; + } + + // 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; + } + + // 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; + + // The history of this annotation. + Provenance provenance = 8; + } + + // Detected language for a structural component. + message DetectedLanguage { + // The BCP-47 language code, such as "en-US" or "sr-Latn". For more + // information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 1; + + // Confidence of detected language. Range [0, 1]. + float confidence = 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; + + // The history of this page. + Provenance provenance = 16; + } + + // A phrase in the text that is a known entity type, such as a person, an + // organization, or location. + message Entity { + // Parsed and normalized entity value. + message NormalizedValue { + // Structured entity value. Must match entity type defined in schema if + // known. If this field is present, the 'text' field is still 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; + } + + // Required. Normalized entity value stored as a string. This field is populated for + // supported document type (e.g. Invoice). For some entity types, one of + // respective 'structured_value' fields may also be populated. + // + // - 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) = REQUIRED]; + } + + // 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]; + + // Entity type from a schema e.g. `Address`. + string type = 2; + + // Optional. Text value in the document 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. + 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 { + // Structure for referencing parent provenances. When an element replaces + // one of more other elements parent references identify the elements that + // are replaced. + message Parent { + // The index of the [Document.revisions] identifying the parent revision. + int32 revision = 1; + + // The index of the parent revisions corresponding collection of items + // (eg. list of entities, properties within entities, etc.) + 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. + OPERATION_TYPE_UNSPECIFIED = 0; + + // Add an element. Implicit if no `parents` are set for the provenance. + ADD = 1; + + // The element is removed. No `parents` should be set. + REMOVE = 2; + + // Explicitly replaces the element(s) identified by `parents`. + REPLACE = 3; + + // Element is requested for human review. + 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; + + // 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; + } + + // 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]; + + // 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; + + // Relationship among [Document.entities][google.cloud.documentai.v1.Document.entities]. + repeated EntityRelation entity_relations = 8; + + // A list of text corrections made to [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; + + // Revision history of this document. + repeated Revision revisions = 13; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_io.proto b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_io.proto new file mode 100644 index 000000000..1bd020eef --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_io.proto @@ -0,0 +1,86 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +import "google/api/annotations.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]. + 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 Cloud Storage uri (a directory) of the output. + string gcs_uri = 1; + } + + // 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/v1/protos/google/cloud/documentai/v1/document_processor_service.proto b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_processor_service.proto new file mode 100644 index 000000000..65f0e6d96 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_processor_service.proto @@ -0,0 +1,301 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.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/operation_metadata.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/Location" + pattern: "projects/{project}/locations/{location}" +}; +option (google.api.resource_definition) = { + type: "documentai.googleapis.com/Processor" + pattern: "projects/{project}/locations/{location}/processors/{processor}" +}; +option (google.api.resource_definition) = { + type: "documentai.googleapis.com/HumanReviewConfig" + pattern: "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" +}; + +// 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: "*" + }; + 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: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "BatchProcessResponse" + metadata_type: "BatchProcessMetadata" + }; + } + + // 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 processor resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; + + // Whether Human Review feature should be skipped for this request. Default to + // false. + bool skip_human_review = 3; +} + +// 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 processor resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; + + // 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 of the processing of 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 review document method. +message ReviewDocumentRequest { + reserved 2; + + // 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; +} + +// Response message for review document method. +message ReviewDocumentResponse { + // The Cloud Storage uri for the human reviewed document. + string gcs_destination = 1; +} + +// The long running operation metadata for review document method. +message ReviewDocumentOperationMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} diff --git a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/geometry.proto b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/geometry.proto new file mode 100644 index 000000000..19ced5073 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/geometry.proto @@ -0,0 +1,57 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +import "google/api/annotations.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 = "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/v1/protos/google/cloud/documentai/v1/operation_metadata.proto b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/operation_metadata.proto new file mode 100644 index 000000000..503451bf2 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/operation_metadata.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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"; +import "google/api/annotations.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; + + // 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/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 000000000..c72080095 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// 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. +// +// ** 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 DocumentProcessorServiceClient = v1.DocumentProcessorServiceClient; +type DocumentProcessorServiceClient = v1.DocumentProcessorServiceClient; +export {v1, DocumentProcessorServiceClient}; +export default {v1, DocumentProcessorServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/document_processor_service_client.ts b/owl-bot-staging/v1/src/v1/document_processor_service_client.ts new file mode 100644 index 000000000..2c9803641 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/document_processor_service_client.ts @@ -0,0 +1,721 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/document_processor_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './document_processor_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * 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. + * @class + * @memberof v1 + */ +export class DocumentProcessorServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + documentProcessorServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DocumentProcessorServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DocumentProcessorServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + humanReviewConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig' + ), + processorPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/processors/{processor}' + ), + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const batchProcessDocumentsResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.BatchProcessResponse') as gax.protobuf.Type; + const batchProcessDocumentsMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.BatchProcessMetadata') as gax.protobuf.Type; + const reviewDocumentResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.ReviewDocumentResponse') as gax.protobuf.Type; + const reviewDocumentMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.ReviewDocumentOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + batchProcessDocumentsResponse.decode.bind(batchProcessDocumentsResponse), + batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata)), + reviewDocument: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + reviewDocumentResponse.decode.bind(reviewDocumentResponse), + reviewDocumentMetadata.decode.bind(reviewDocumentMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.documentai.v1.DocumentProcessorService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.documentProcessorServiceStub) { + return this.documentProcessorServiceStub; + } + + // Put together the "service stub" for + // google.cloud.documentai.v1.DocumentProcessorService. + this.documentProcessorServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.documentai.v1.DocumentProcessorService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.documentai.v1.DocumentProcessorService, + 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 documentProcessorServiceStubMethods = + ['processDocument', 'batchProcessDocuments', 'reviewDocument']; + for (const methodName of documentProcessorServiceStubMethods) { + const callPromise = this.documentProcessorServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.documentProcessorServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'documentai.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 'documentai.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 -- + // ------------------- + processDocument( + request?: protos.google.cloud.documentai.v1.IProcessRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1.IProcessResponse, + protos.google.cloud.documentai.v1.IProcessRequest|undefined, {}|undefined + ]>; + processDocument( + request: protos.google.cloud.documentai.v1.IProcessRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1.IProcessResponse, + protos.google.cloud.documentai.v1.IProcessRequest|null|undefined, + {}|null|undefined>): void; + processDocument( + request: protos.google.cloud.documentai.v1.IProcessRequest, + callback: Callback< + protos.google.cloud.documentai.v1.IProcessResponse, + protos.google.cloud.documentai.v1.IProcessRequest|null|undefined, + {}|null|undefined>): void; +/** + * Processes a single document. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.documentai.v1.Document} request.inlineDocument + * An inline document proto. + * @param {google.cloud.documentai.v1.RawDocument} request.rawDocument + * A raw document content (bytes). + * @param {string} request.name + * Required. The processor resource name. + * @param {boolean} request.skipHumanReview + * Whether Human Review feature should be skipped for this request. Default to + * false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProcessResponse]{@link google.cloud.documentai.v1.ProcessResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.processDocument(request); + */ + processDocument( + request?: protos.google.cloud.documentai.v1.IProcessRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1.IProcessResponse, + protos.google.cloud.documentai.v1.IProcessRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1.IProcessResponse, + protos.google.cloud.documentai.v1.IProcessRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1.IProcessResponse, + protos.google.cloud.documentai.v1.IProcessRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.processDocument(request, options, callback); + } + + batchProcessDocuments( + request?: protos.google.cloud.documentai.v1.IBatchProcessRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + batchProcessDocuments( + request: protos.google.cloud.documentai.v1.IBatchProcessRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + batchProcessDocuments( + request: protos.google.cloud.documentai.v1.IBatchProcessRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * LRO endpoint to batch process many documents. The output is written + * to Cloud Storage as JSON in the [Document] format. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor resource name. + * @param {google.cloud.documentai.v1.BatchDocumentsInputConfig} request.inputDocuments + * The input documents for batch process. + * @param {google.cloud.documentai.v1.DocumentOutputConfig} request.documentOutputConfig + * The overall output config for batch process. + * @param {boolean} request.skipHumanReview + * Whether Human Review feature should be skipped for this request. Default to + * false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.batchProcessDocuments(request); + * const [response] = await operation.promise(); + */ + batchProcessDocuments( + request?: protos.google.cloud.documentai.v1.IBatchProcessRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.batchProcessDocuments(request, options, callback); + } +/** + * Check the status of the long running operation returned by `batchProcessDocuments()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkBatchProcessDocumentsProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkBatchProcessDocumentsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + reviewDocument( + request?: protos.google.cloud.documentai.v1.IReviewDocumentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + reviewDocument( + request: protos.google.cloud.documentai.v1.IReviewDocumentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + reviewDocument( + request: protos.google.cloud.documentai.v1.IReviewDocumentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Send a document for Human Review. The input document should be processed by + * the specified processor. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.documentai.v1.Document} request.inlineDocument + * An inline document proto. + * @param {string} request.humanReviewConfig + * Required. The resource name of the HumanReviewConfig that the document will be + * reviewed with. + * @param {boolean} request.enableSchemaValidation + * Whether the validation should be performed on the ad-hoc review request. + * @param {google.cloud.documentai.v1.ReviewDocumentRequest.Priority} request.priority + * The priority of the human review task. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.reviewDocument(request); + * const [response] = await operation.promise(); + */ + reviewDocument( + request?: protos.google.cloud.documentai.v1.IReviewDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'human_review_config': request.humanReviewConfig || '', + }); + this.initialize(); + return this.innerApiCalls.reviewDocument(request, options, callback); + } +/** + * Check the status of the long running operation returned by `reviewDocument()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkReviewDocumentProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkReviewDocumentProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.reviewDocument, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified humanReviewConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} processor + * @returns {string} Resource name string. + */ + humanReviewConfigPath(project:string,location:string,processor:string) { + return this.pathTemplates.humanReviewConfigPathTemplate.render({ + project: project, + location: location, + processor: processor, + }); + } + + /** + * Parse the project from HumanReviewConfig resource. + * + * @param {string} humanReviewConfigName + * A fully-qualified path representing HumanReviewConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromHumanReviewConfigName(humanReviewConfigName: string) { + return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).project; + } + + /** + * Parse the location from HumanReviewConfig resource. + * + * @param {string} humanReviewConfigName + * A fully-qualified path representing HumanReviewConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromHumanReviewConfigName(humanReviewConfigName: string) { + return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).location; + } + + /** + * Parse the processor from HumanReviewConfig resource. + * + * @param {string} humanReviewConfigName + * A fully-qualified path representing HumanReviewConfig resource. + * @returns {string} A string representing the processor. + */ + matchProcessorFromHumanReviewConfigName(humanReviewConfigName: string) { + return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).processor; + } + + /** + * Return a fully-qualified processor resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} processor + * @returns {string} Resource name string. + */ + processorPath(project:string,location:string,processor:string) { + return this.pathTemplates.processorPathTemplate.render({ + project: project, + location: location, + processor: processor, + }); + } + + /** + * Parse the project from Processor resource. + * + * @param {string} processorName + * A fully-qualified path representing Processor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProcessorName(processorName: string) { + return this.pathTemplates.processorPathTemplate.match(processorName).project; + } + + /** + * Parse the location from Processor resource. + * + * @param {string} processorName + * A fully-qualified path representing Processor resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProcessorName(processorName: string) { + return this.pathTemplates.processorPathTemplate.match(processorName).location; + } + + /** + * Parse the processor from Processor resource. + * + * @param {string} processorName + * A fully-qualified path representing Processor resource. + * @returns {string} A string representing the processor. + */ + matchProcessorFromProcessorName(processorName: string) { + return this.pathTemplates.processorPathTemplate.match(processorName).processor; + } + + /** + * 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 { + this.initialize(); + if (!this._terminated) { + return this.documentProcessorServiceStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/document_processor_service_client_config.json b/owl-bot-staging/v1/src/v1/document_processor_service_client_config.json new file mode 100644 index 000000000..0ded43290 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/document_processor_service_client_config.json @@ -0,0 +1,41 @@ +{ + "interfaces": { + "google.cloud.documentai.v1.DocumentProcessorService": { + "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": { + "ProcessDocument": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchProcessDocuments": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ReviewDocument": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/document_processor_service_proto_list.json b/owl-bot-staging/v1/src/v1/document_processor_service_proto_list.json new file mode 100644 index 000000000..49fea13a7 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/document_processor_service_proto_list.json @@ -0,0 +1,7 @@ +[ + "../../protos/google/cloud/documentai/v1/document.proto", + "../../protos/google/cloud/documentai/v1/document_io.proto", + "../../protos/google/cloud/documentai/v1/document_processor_service.proto", + "../../protos/google/cloud/documentai/v1/geometry.proto", + "../../protos/google/cloud/documentai/v1/operation_metadata.proto" +] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 000000000..05ebff671 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,53 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.documentai.v1", + "libraryPackage": "@google-cloud/documentai", + "services": { + "DocumentProcessorService": { + "clients": { + "grpc": { + "libraryClient": "DocumentProcessorServiceClient", + "rpcs": { + "ProcessDocument": { + "methods": [ + "processDocument" + ] + }, + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + }, + "ReviewDocument": { + "methods": [ + "reviewDocument" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentProcessorServiceClient", + "rpcs": { + "ProcessDocument": { + "methods": [ + "processDocument" + ] + }, + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + }, + "ReviewDocument": { + "methods": [ + "reviewDocument" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 000000000..2f6c91a42 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// 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. +// +// ** 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 {DocumentProcessorServiceClient} from './document_processor_service_client'; diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 000000000..7a0b0174d --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// 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. +// +// ** 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 documentai = require('@google-cloud/documentai'); + +function main() { + const documentProcessorServiceClient = new documentai.DocumentProcessorServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 000000000..2bccab99e --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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. +// +// ** 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 {DocumentProcessorServiceClient} from '@google-cloud/documentai'; + +// check that the client class type name can be used +function doStuffWithDocumentProcessorServiceClient(client: DocumentProcessorServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const documentProcessorServiceClient = new DocumentProcessorServiceClient(); + doStuffWithDocumentProcessorServiceClient(documentProcessorServiceClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 000000000..1f850b522 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1/test/gapic_document_processor_service_v1.ts b/owl-bot-staging/v1/test/gapic_document_processor_service_v1.ts new file mode 100644 index 000000000..801a74e6d --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_document_processor_service_v1.ts @@ -0,0 +1,603 @@ +// 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. +// +// ** 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 documentprocessorserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1.DocumentProcessorServiceClient', () => { + it('has servicePath', () => { + const servicePath = documentprocessorserviceModule.v1.DocumentProcessorServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = documentprocessorserviceModule.v1.DocumentProcessorServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = documentprocessorserviceModule.v1.DocumentProcessorServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentProcessorServiceStub, undefined); + await client.initialize(); + assert(client.documentProcessorServiceStub); + }); + + it('has close method', () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + 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 documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + 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('processDocument', () => { + it('invokes processDocument without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessResponse()); + client.innerApiCalls.processDocument = stubSimpleCall(expectedResponse); + const [response] = await client.processDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.processDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes processDocument without error using callback', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessResponse()); + client.innerApiCalls.processDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.processDocument( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.processDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes processDocument with error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.processDocument(request), expectedError); + assert((client.innerApiCalls.processDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('batchProcessDocuments', () => { + it('invokes batchProcessDocuments without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.BatchProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(expectedResponse); + const [operation] = await client.batchProcessDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchProcessDocuments without error using callback', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.BatchProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchProcessDocuments( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchProcessDocuments with call error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.BatchProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.batchProcessDocuments(request), expectedError); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchProcessDocuments with LRO error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.BatchProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.batchProcessDocuments(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkBatchProcessDocumentsProgress without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchProcessDocumentsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkBatchProcessDocumentsProgress with error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkBatchProcessDocumentsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('reviewDocument', () => { + it('invokes reviewDocument without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ReviewDocumentRequest()); + request.humanReviewConfig = ''; + const expectedHeaderRequestParams = "human_review_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.reviewDocument = stubLongRunningCall(expectedResponse); + const [operation] = await client.reviewDocument(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes reviewDocument without error using callback', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ReviewDocumentRequest()); + request.humanReviewConfig = ''; + const expectedHeaderRequestParams = "human_review_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.reviewDocument = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reviewDocument( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes reviewDocument with call error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ReviewDocumentRequest()); + request.humanReviewConfig = ''; + const expectedHeaderRequestParams = "human_review_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.reviewDocument(request), expectedError); + assert((client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes reviewDocument with LRO error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ReviewDocumentRequest()); + request.humanReviewConfig = ''; + const expectedHeaderRequestParams = "human_review_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.reviewDocument(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkReviewDocumentProgress without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkReviewDocumentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkReviewDocumentProgress with error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkReviewDocumentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('Path templates', () => { + + describe('humanReviewConfig', () => { + const fakePath = "/rendered/path/humanReviewConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + processor: "processorValue", + }; + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.humanReviewConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.humanReviewConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('humanReviewConfigPath', () => { + const result = client.humanReviewConfigPath("projectValue", "locationValue", "processorValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.humanReviewConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromHumanReviewConfigName', () => { + const result = client.matchProjectFromHumanReviewConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromHumanReviewConfigName', () => { + const result = client.matchLocationFromHumanReviewConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorFromHumanReviewConfigName', () => { + const result = client.matchProcessorFromHumanReviewConfigName(fakePath); + assert.strictEqual(result, "processorValue"); + assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('processor', () => { + const fakePath = "/rendered/path/processor"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + processor: "processorValue", + }; + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.processorPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.processorPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('processorPath', () => { + const result = client.processorPath("projectValue", "locationValue", "processorValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.processorPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProcessorName', () => { + const result = client.matchProjectFromProcessorName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.processorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProcessorName', () => { + const result = client.matchLocationFromProcessorName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.processorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorFromProcessorName', () => { + const result = client.matchProcessorFromProcessorName(fakePath); + assert.strictEqual(result, "processorValue"); + assert((client.pathTemplates.processorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 000000000..fc7bef574 --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'DocumentProcessorService', + filename: './document-processor-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/owl-bot-staging/v1beta1/.eslintignore b/owl-bot-staging/v1beta1/.eslintignore new file mode 100644 index 000000000..521dc25a2 --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintignore @@ -0,0 +1,6 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ diff --git a/owl-bot-staging/v1beta1/.eslintrc.json b/owl-bot-staging/v1beta1/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1beta1/.gitignore b/owl-bot-staging/v1beta1/.gitignore new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/owl-bot-staging/v1beta1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1beta1/.jsdoc.js b/owl-bot-staging/v1beta1/.jsdoc.js new file mode 100644 index 000000000..b9a6b9977 --- /dev/null +++ b/owl-bot-staging/v1beta1/.jsdoc.js @@ -0,0 +1,55 @@ +// 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. +// +// ** This file 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 2021 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: 'documentai', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1beta1/.mocharc.js b/owl-bot-staging/v1beta1/.mocharc.js new file mode 100644 index 000000000..50bc7f792 --- /dev/null +++ b/owl-bot-staging/v1beta1/.mocharc.js @@ -0,0 +1,33 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1beta1/.prettierrc.js b/owl-bot-staging/v1beta1/.prettierrc.js new file mode 100644 index 000000000..84f4713a0 --- /dev/null +++ b/owl-bot-staging/v1beta1/.prettierrc.js @@ -0,0 +1,22 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1beta1/README.md b/owl-bot-staging/v1beta1/README.md new file mode 100644 index 000000000..f41eef852 --- /dev/null +++ b/owl-bot-staging/v1beta1/README.md @@ -0,0 +1 @@ +Documentai: Nodejs Client diff --git a/owl-bot-staging/v1beta1/linkinator.config.json b/owl-bot-staging/v1beta1/linkinator.config.json new file mode 100644 index 000000000..29a223b6d --- /dev/null +++ b/owl-bot-staging/v1beta1/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json new file mode 100644 index 000000000..b990b7473 --- /dev/null +++ b/owl-bot-staging/v1beta1/package.json @@ -0,0 +1,64 @@ +{ + "name": "documentai", + "version": "0.1.0", + "description": "Documentai client for Node.js", + "repository": "googleapis/nodejs-documentai", + "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 documentai", + "documentai", + "document understanding service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.19.0" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@types/node": "^14.17.3", + "@types/sinon": "^10.0.2", + "c8": "^7.7.3", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.0", + "jsdoc-region-tag": "^1.1.0", + "linkinator": "^2.13.6", + "mocha": "^9.0.2", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.1", + "ts-loader": "^9.2.3", + "typescript": "^4.3.4", + "webpack": "^5.39.1", + "webpack-cli": "^4.7.2" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto b/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto new file mode 100644 index 000000000..2c47f6f22 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto @@ -0,0 +1,449 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.cloud.documentai.v1beta1; + +import "google/api/annotations.proto"; +import "google/cloud/documentai/v1beta1/geometry.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.cloud.documentai.v1beta1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta1"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta1"; + +// Document represents the canonical document resource in Document Understanding +// AI. +// It is an interchange format that provides insights into documents and allows +// for collaboration between users and Document Understanding 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.v1beta1.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.v1beta1.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; + } + + // A page in a [Document][google.cloud.documentai.v1beta1.Document]. + message Page { + // Dimension for the page. + message Dimension { + // Page width. + float width = 1; + + // Page height. + float height = 2; + + // Dimension unit. + string unit = 3; + } + + // 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.v1beta1.Document.text]. + TextAnchor text_anchor = 1; + + // Confidence of the current + // [Layout][google.cloud.documentai.v1beta1.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.v1beta1.Document.Page.Layout]. + BoundingPoly bounding_poly = 3; + + // Detected orientation for the + // [Layout][google.cloud.documentai.v1beta1.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.v1beta1.Document.Page.Layout] for + // [Block][google.cloud.documentai.v1beta1.Document.Page.Block]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + } + + // A collection of lines that a human would perceive as a paragraph. + message Paragraph { + // [Layout][google.cloud.documentai.v1beta1.Document.Page.Layout] for + // [Paragraph][google.cloud.documentai.v1beta1.Document.Page.Paragraph]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + } + + // 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.v1beta1.Document.Page.Layout] for + // [Line][google.cloud.documentai.v1beta1.Document.Page.Line]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + } + + // A detected token. + message Token { + // Detected break at the end of a + // [Token][google.cloud.documentai.v1beta1.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.v1beta1.Document.Page.Layout] for + // [Token][google.cloud.documentai.v1beta1.Document.Page.Token]. + Layout layout = 1; + + // Detected break at the end of a + // [Token][google.cloud.documentai.v1beta1.Document.Page.Token]. + DetectedBreak detected_break = 2; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 3; + } + + // Detected non-text visual elements e.g. checkbox, signature etc. on the + // page. + message VisualElement { + // [Layout][google.cloud.documentai.v1beta1.Document.Page.Layout] for + // [Token][google.cloud.documentai.v1beta1.Document.Page.Token]. + Layout layout = 1; + + // Type of the + // [VisualElement][google.cloud.documentai.v1beta1.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.v1beta1.Document.Page.Layout] for + // [TableCell][google.cloud.documentai.v1beta1.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.v1beta1.Document.Page.Layout] for + // [Table][google.cloud.documentai.v1beta1.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; + } + + // A form field detected on the page. + message FormField { + // [Layout][google.cloud.documentai.v1beta1.Document.Page.Layout] for the + // [FormField][google.cloud.documentai.v1beta1.Document.Page.FormField] + // name. e.g. `Address`, `Email`, `Grand total`, `Phone number`, etc. + Layout field_name = 1; + + // [Layout][google.cloud.documentai.v1beta1.Document.Page.Layout] for the + // [FormField][google.cloud.documentai.v1beta1.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; + } + + // Detected language for a structural component. + message DetectedLanguage { + // The BCP-47 language code, such as "en-US" or "sr-Latn". For more + // information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 1; + + // Confidence of detected language. Range [0, 1]. + float confidence = 2; + } + + // 1-based index for current + // [Page][google.cloud.documentai.v1beta1.Document.Page] in a parent + // [Document][google.cloud.documentai.v1beta1.Document]. Useful when a page + // is taken out of a [Document][google.cloud.documentai.v1beta1.Document] + // for individual processing. + int32 page_number = 1; + + // Physical dimension of the page. + Dimension dimension = 2; + + // [Layout][google.cloud.documentai.v1beta1.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 phrase in the text that is a known entity type, such as a person, an + // organization, or location. + message Entity { + // Provenance of the entity. + // Text anchor indexing into the + // [Document.text][google.cloud.documentai.v1beta1.Document.text]. + TextAnchor text_anchor = 1; + + // Entity type from a schema e.g. `Address`. + string type = 2; + + // Text value in the document e.g. `1600 Amphitheatre Pkwy`. + string mention_text = 3; + + // Canonical mention name. This will be a unique value in the entity list + // for this document. + string mention_id = 4; + } + + // Relationship between + // [Entities][google.cloud.documentai.v1beta1.Document.Entity]. + message EntityRelation { + // Subject entity mention_id. + string subject_id = 1; + + // Object entity mention_id. + string object_id = 2; + + // Relationship description. + string relation = 3; + } + + // Text reference indexing into the + // [Document.text][google.cloud.documentai.v1beta1.Document.text]. + message TextAnchor { + // A text segment in the + // [Document.text][google.cloud.documentai.v1beta1.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.v1beta1.Document.ShardInfo.text_offset] + message TextSegment { + // [TextSegment][google.cloud.documentai.v1beta1.Document.TextAnchor.TextSegment] + // start UTF-8 char index in the + // [Document.text][google.cloud.documentai.v1beta1.Document.text]. + int64 start_index = 1; + + // [TextSegment][google.cloud.documentai.v1beta1.Document.TextAnchor.TextSegment] + // half open end UTF-8 char index in the + // [Document.text][google.cloud.documentai.v1beta1.Document.text]. + int64 end_index = 2; + } + + // The text segments from the + // [Document.text][google.cloud.documentai.v1beta1.Document.text]. + repeated TextSegment text_segments = 1; + } + + // Original source document from the user. + oneof source { + // 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; + + // 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; + } + + // 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; + + // UTF-8 encoded text in reading order from the document. + string text = 4; + + // Styles for the + // [Document.text][google.cloud.documentai.v1beta1.Document.text]. + repeated Style text_styles = 5; + + // Visual page layout for the + // [Document][google.cloud.documentai.v1beta1.Document]. + repeated Page pages = 6; + + // A list of entities detected on + // [Document.text][google.cloud.documentai.v1beta1.Document.text]. For + // document shards, entities in this list may cross shard boundaries. + repeated Entity entities = 7; + + // Relationship among + // [Document.entities][google.cloud.documentai.v1beta1.Document.entities]. + repeated EntityRelation entity_relations = 8; + + // 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; +} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto b/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto new file mode 100644 index 000000000..eb17286d4 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto @@ -0,0 +1,302 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.cloud.documentai.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/documentai/v1beta1/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProto"; +option java_package = "com.google.cloud.documentai.v1beta1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta1"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta1"; + +// Service to parse structured information from unstructured or semi-structured +// documents using state-of-the-art Google AI such as natural language, +// computer vision, and translation. +service DocumentUnderstandingService { + option (google.api.default_host) = "documentai.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // LRO endpoint to batch process many documents. + rpc BatchProcessDocuments(BatchProcessDocumentsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta1/{parent=projects/*/locations/*}/documents:batchProcess" + body: "*" + additional_bindings { + post: "/v1beta1/{parent=projects/*}/documents:batchProcess" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "BatchProcessDocumentsResponse" + metadata_type: "OperationMetadata" + }; + } +} + +// Request to batch process documents as an asynchronous operation. +message BatchProcessDocumentsRequest { + // Required. Individual requests for each document. + repeated ProcessDocumentRequest requests = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no location is specified, a region will be chosen automatically. + string parent = 2; +} + +// Request to process one document. +message ProcessDocumentRequest { + // Required. Information about the input file. + InputConfig input_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The desired output location. + OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; + + // Specifies a known document type for deeper structure detection. Valid + // values are currently "general" and "invoice". If not provided, "general"\ + // is used as default. If any other value is given, the request is rejected. + string document_type = 3; + + // Controls table extraction behavior. If not specified, the system will + // decide reasonable defaults. + TableExtractionParams table_extraction_params = 4; + + // Controls form extraction behavior. If not specified, the system will + // decide reasonable defaults. + FormExtractionParams form_extraction_params = 5; + + // Controls entity extraction behavior. If not specified, the system will + // decide reasonable defaults. + EntityExtractionParams entity_extraction_params = 6; + + // Controls OCR behavior. If not specified, the system will decide reasonable + // defaults. + OcrParams ocr_params = 7; +} + +// Response to an batch document processing request. This is returned in +// the LRO Operation after the operation is complete. +message BatchProcessDocumentsResponse { + // Responses for each individual document. + repeated ProcessDocumentResponse responses = 1; +} + +// Response to a single document processing request. +message ProcessDocumentResponse { + // Information about the input file. This is the same as the corresponding + // input config in the request. + InputConfig input_config = 1; + + // The output location of the parsed responses. The responses are written to + // this location as JSON-serialized `Document` objects. + OutputConfig output_config = 2; +} + +// Parameters to control Optical Character Recognition (OCR) behavior. +message OcrParams { + // List of languages to use for OCR. In most cases, an empty value + // yields the best results since it enables automatic language detection. For + // languages based on the Latin alphabet, setting `language_hints` is not + // needed. In rare cases, when the language of the text in the image is known, + // setting a hint will help get better results (although it will be a + // significant hindrance if the hint is wrong). Document processing returns an + // error if one or more of the specified languages is not one of the + // supported languages. + repeated string language_hints = 1; +} + +// Parameters to control table extraction behavior. +message TableExtractionParams { + // Whether to enable table extraction. + bool enabled = 1; + + // Optional. Table bounding box hints that can be provided to complex cases + // which our algorithm cannot locate the table(s) in. + repeated TableBoundHint table_bound_hints = 2 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Table header hints. The extraction will bias towards producing + // these terms as table headers, which may improve accuracy. + repeated string header_hints = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Model version of the table extraction system. Default is "builtin/stable". + // Specify "builtin/latest" for the latest model. + string model_version = 4; +} + +// A hint for a table bounding box on the page for table parsing. +message TableBoundHint { + // Optional. Page number for multi-paged inputs this hint applies to. If not + // provided, this hint will apply to all pages by default. This value is + // 1-based. + int32 page_number = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Bounding box hint for a table on this page. The coordinates must be + // normalized to [0,1] and the bounding box must be an axis-aligned rectangle. + BoundingPoly bounding_box = 2; +} + +// Parameters to control form extraction behavior. +message FormExtractionParams { + // Whether to enable form extraction. + bool enabled = 1; + + // User can provide pairs of (key text, value type) to improve the parsing + // result. + // + // For example, if a document has a field called "Date" that holds a date + // value and a field called "Amount" that may hold either a currency value + // (e.g., "$500.00") or a simple number value (e.g., "20"), you could use the + // following hints: [ {"key": "Date", value_types: [ "DATE"]}, {"key": + // "Amount", "value_types": [ "PRICE", "NUMBER" ]} ] + // + // If the value type is unknown, but you want to provide hints for the keys, + // you can leave the value_types field blank. e.g. {"key": "Date", + // "value_types": []} + repeated KeyValuePairHint key_value_pair_hints = 2; + + // Model version of the form extraction system. Default is + // "builtin/stable". Specify "builtin/latest" for the latest model. + string model_version = 3; +} + +// User-provided hint for key value pair. +message KeyValuePairHint { + // The key text for the hint. + string key = 1; + + // Type of the value. This is case-insensitive, and could be one of: + // ADDRESS, LOCATION, ORGANIZATION, PERSON, PHONE_NUMBER, + // ID, NUMBER, EMAIL, PRICE, TERMS, DATE, NAME. Types not in this list will + // be ignored. + repeated string value_types = 2; +} + +// Parameters to control entity extraction behavior. +message EntityExtractionParams { + // Whether to enable entity extraction. + bool enabled = 1; + + // Model version of the entity extraction. Default is + // "builtin/stable". Specify "builtin/latest" for the latest model. + string model_version = 2; +} + +// The desired input location and metadata. +message InputConfig { + // Required. + oneof source { + // The Google Cloud Storage location to read the input from. This must be a + // single file. + GcsSource gcs_source = 1; + } + + // Required. Mimetype of the input. Current supported mimetypes are + // application/pdf, image/tiff, and image/gif. + string mime_type = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The desired output location and metadata. +message OutputConfig { + // Required. + oneof destination { + // The Google Cloud Storage location to write the output to. + GcsDestination gcs_destination = 1; + } + + // The max number of pages to include into each output Document shard JSON on + // Google Cloud Storage. + // + // The valid range is [1, 100]. If not specified, the default value is 20. + // + // For example, for one pdf file with 100 pages, 100 parsed pages will be + // produced. If `pages_per_shard` = 20, then 5 Document shard JSON files each + // containing 20 parsed pages will be written under the prefix + // [OutputConfig.gcs_destination.uri][] and suffix pages-x-to-y.json where + // x and y are 1-indexed page numbers. + // + // Example GCS outputs with 157 pages and pages_per_shard = 50: + // + // pages-001-to-050.json + // pages-051-to-100.json + // pages-101-to-150.json + // pages-151-to-157.json + int32 pages_per_shard = 2; +} + +// The Google Cloud Storage location where the input file will be read from. +message GcsSource { + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The Google Cloud Storage location where the output file will be written to. +message GcsDestination { + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Contains metadata for the BatchProcessDocuments operation. +message OperationMetadata { + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // Request is received. + ACCEPTED = 1; + + // Request operation is waiting for scheduling. + WAITING = 2; + + // Request is being processed. + RUNNING = 3; + + // The batch processing completed successfully. + SUCCEEDED = 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. + 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; +} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto b/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto new file mode 100644 index 000000000..631c179c3 --- /dev/null +++ b/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto @@ -0,0 +1,58 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.cloud.documentai.v1beta1; + +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.documentai.v1beta1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta1"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta1"; + +// 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. + 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. + 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/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts new file mode 100644 index 000000000..2e481c053 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1beta1 from './v1beta1'; +const DocumentUnderstandingServiceClient = v1beta1.DocumentUnderstandingServiceClient; +type DocumentUnderstandingServiceClient = v1beta1.DocumentUnderstandingServiceClient; +export {v1beta1, DocumentUnderstandingServiceClient}; +export default {v1beta1, DocumentUnderstandingServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client.ts new file mode 100644 index 000000000..a0e9f0bf5 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client.ts @@ -0,0 +1,415 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta1/document_understanding_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './document_understanding_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service to parse structured information from unstructured or semi-structured + * documents using state-of-the-art Google AI such as natural language, + * computer vision, and translation. + * @class + * @memberof v1beta1 + */ +export class DocumentUnderstandingServiceClient { + 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}; + operationsClient: gax.OperationsClient; + documentUnderstandingServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DocumentUnderstandingServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DocumentUnderstandingServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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); + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const batchProcessDocumentsResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta1.BatchProcessDocumentsResponse') as gax.protobuf.Type; + const batchProcessDocumentsMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta1.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + batchProcessDocumentsResponse.decode.bind(batchProcessDocumentsResponse), + batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.documentai.v1beta1.DocumentUnderstandingService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.documentUnderstandingServiceStub) { + return this.documentUnderstandingServiceStub; + } + + // Put together the "service stub" for + // google.cloud.documentai.v1beta1.DocumentUnderstandingService. + this.documentUnderstandingServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.documentai.v1beta1.DocumentUnderstandingService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.documentai.v1beta1.DocumentUnderstandingService, + 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 documentUnderstandingServiceStubMethods = + ['batchProcessDocuments']; + for (const methodName of documentUnderstandingServiceStubMethods) { + const callPromise = this.documentUnderstandingServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.documentUnderstandingServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'documentai.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 'documentai.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 -- + // ------------------- + + batchProcessDocuments( + request?: protos.google.cloud.documentai.v1beta1.IBatchProcessDocumentsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + batchProcessDocuments( + request: protos.google.cloud.documentai.v1beta1.IBatchProcessDocumentsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + batchProcessDocuments( + request: protos.google.cloud.documentai.v1beta1.IBatchProcessDocumentsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * LRO endpoint to batch process many documents. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual requests for each document. + * @param {string} request.parent + * Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no location is specified, a region will be chosen automatically. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.batchProcessDocuments(request); + * const [response] = await operation.promise(); + */ + batchProcessDocuments( + request?: protos.google.cloud.documentai.v1beta1.IBatchProcessDocumentsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.batchProcessDocuments(request, options, callback); + } +/** + * Check the status of the long running operation returned by `batchProcessDocuments()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkBatchProcessDocumentsProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkBatchProcessDocumentsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + + /** + * 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 { + this.initialize(); + if (!this._terminated) { + return this.documentUnderstandingServiceStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client_config.json new file mode 100644 index 000000000..2b4b0aff7 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client_config.json @@ -0,0 +1,31 @@ +{ + "interfaces": { + "google.cloud.documentai.v1beta1.DocumentUnderstandingService": { + "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": { + "BatchProcessDocuments": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_proto_list.json new file mode 100644 index 000000000..684a577c0 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/documentai/v1beta1/document.proto", + "../../protos/google/cloud/documentai/v1beta1/document_understanding.proto", + "../../protos/google/cloud/documentai/v1beta1/geometry.proto" +] diff --git a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 000000000..ec68421d5 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json @@ -0,0 +1,33 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.documentai.v1beta1", + "libraryPackage": "documentai", + "services": { + "DocumentUnderstandingService": { + "clients": { + "grpc": { + "libraryClient": "DocumentUnderstandingServiceClient", + "rpcs": { + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentUnderstandingServiceClient", + "rpcs": { + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/v1beta1/src/v1beta1/index.ts new file mode 100644 index 000000000..1a00861f8 --- /dev/null +++ b/owl-bot-staging/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// 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. +// +// ** 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 {DocumentUnderstandingServiceClient} from './document_understanding_service_client'; diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 000000000..7835b7bc5 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// 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. +// +// ** 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 documentai = require('documentai'); + +function main() { + const documentUnderstandingServiceClient = new documentai.DocumentUnderstandingServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 000000000..d399cead7 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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. +// +// ** 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 {DocumentUnderstandingServiceClient} from 'documentai'; + +// check that the client class type name can be used +function doStuffWithDocumentUnderstandingServiceClient(client: DocumentUnderstandingServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const documentUnderstandingServiceClient = new DocumentUnderstandingServiceClient(); + doStuffWithDocumentUnderstandingServiceClient(documentUnderstandingServiceClient); +} + +main(); diff --git a/owl-bot-staging/v1beta1/system-test/install.ts b/owl-bot-staging/v1beta1/system-test/install.ts new file mode 100644 index 000000000..1f850b522 --- /dev/null +++ b/owl-bot-staging/v1beta1/system-test/install.ts @@ -0,0 +1,49 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1beta1/test/gapic_document_understanding_service_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_document_understanding_service_v1beta1.ts new file mode 100644 index 000000000..8fd3a94c0 --- /dev/null +++ b/owl-bot-staging/v1beta1/test/gapic_document_understanding_service_v1beta1.ts @@ -0,0 +1,276 @@ +// 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. +// +// ** 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 documentunderstandingserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1beta1.DocumentUnderstandingServiceClient', () => { + it('has servicePath', () => { + const servicePath = documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentUnderstandingServiceStub, undefined); + await client.initialize(); + assert(client.documentUnderstandingServiceStub); + }); + + it('has close method', () => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + 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 documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + 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('batchProcessDocuments', () => { + it('invokes batchProcessDocuments without error', async () => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(expectedResponse); + const [operation] = await client.batchProcessDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchProcessDocuments without error using callback', async () => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchProcessDocuments( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchProcessDocuments with call error', async () => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.batchProcessDocuments(request), expectedError); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchProcessDocuments with LRO error', async () => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.batchProcessDocuments(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkBatchProcessDocumentsProgress without error', async () => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchProcessDocumentsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkBatchProcessDocumentsProgress with error', async () => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkBatchProcessDocumentsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); +}); diff --git a/owl-bot-staging/v1beta1/tsconfig.json b/owl-bot-staging/v1beta1/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/v1beta1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1beta1/webpack.config.js b/owl-bot-staging/v1beta1/webpack.config.js new file mode 100644 index 000000000..c6fdde565 --- /dev/null +++ b/owl-bot-staging/v1beta1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'DocumentUnderstandingService', + filename: './document-understanding-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/owl-bot-staging/v1beta2/.eslintignore b/owl-bot-staging/v1beta2/.eslintignore new file mode 100644 index 000000000..521dc25a2 --- /dev/null +++ b/owl-bot-staging/v1beta2/.eslintignore @@ -0,0 +1,6 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ diff --git a/owl-bot-staging/v1beta2/.eslintrc.json b/owl-bot-staging/v1beta2/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/v1beta2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1beta2/.gitignore b/owl-bot-staging/v1beta2/.gitignore new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/owl-bot-staging/v1beta2/.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/v1beta2/.jsdoc.js b/owl-bot-staging/v1beta2/.jsdoc.js new file mode 100644 index 000000000..a00b08ce2 --- /dev/null +++ b/owl-bot-staging/v1beta2/.jsdoc.js @@ -0,0 +1,55 @@ +// 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. +// +// ** This file 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 2021 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/documentai', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1beta2/.mocharc.js b/owl-bot-staging/v1beta2/.mocharc.js new file mode 100644 index 000000000..50bc7f792 --- /dev/null +++ b/owl-bot-staging/v1beta2/.mocharc.js @@ -0,0 +1,33 @@ +// 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. +// +// ** 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/v1beta2/.prettierrc.js b/owl-bot-staging/v1beta2/.prettierrc.js new file mode 100644 index 000000000..84f4713a0 --- /dev/null +++ b/owl-bot-staging/v1beta2/.prettierrc.js @@ -0,0 +1,22 @@ +// 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. +// +// ** 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/v1beta2/README.md b/owl-bot-staging/v1beta2/README.md new file mode 100644 index 000000000..f41eef852 --- /dev/null +++ b/owl-bot-staging/v1beta2/README.md @@ -0,0 +1 @@ +Documentai: Nodejs Client diff --git a/owl-bot-staging/v1beta2/linkinator.config.json b/owl-bot-staging/v1beta2/linkinator.config.json new file mode 100644 index 000000000..29a223b6d --- /dev/null +++ b/owl-bot-staging/v1beta2/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1beta2/package.json b/owl-bot-staging/v1beta2/package.json new file mode 100644 index 000000000..0e76de79e --- /dev/null +++ b/owl-bot-staging/v1beta2/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/documentai", + "version": "0.1.0", + "description": "Documentai client for Node.js", + "repository": "googleapis/nodejs-documentai", + "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 documentai", + "documentai", + "document understanding service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.19.0" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@types/node": "^14.17.3", + "@types/sinon": "^10.0.2", + "c8": "^7.7.3", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.0", + "jsdoc-region-tag": "^1.1.0", + "linkinator": "^2.13.6", + "mocha": "^9.0.2", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.1", + "ts-loader": "^9.2.3", + "typescript": "^4.3.4", + "webpack": "^5.39.1", + "webpack-cli": "^4.7.2" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto b/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto new file mode 100644 index 000000000..bb3b58bad --- /dev/null +++ b/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto @@ -0,0 +1,519 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta2; + +import "google/api/field_behavior.proto"; +import "google/cloud/documentai/v1beta2/geometry.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta2;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.cloud.documentai.v1beta2"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta2"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta2"; + +// Document represents the canonical document resource in Document Understanding +// AI. +// It is an interchange format that provides insights into documents and allows +// for collaboration between users and Document Understanding 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.v1beta2.Document.text] in the overall + // document global text. + int64 text_offset = 3; + } + + // Label attaches schema information and/or other metadata to segments within + // a [Document][google.cloud.documentai.v1beta2.Document]. Multiple [Label][google.cloud.documentai.v1beta2.Document.Label]s on a single field can denote either + // different labels, different instances of the same label created at + // different times, or some combination of both. + message Label { + // Provenance of the label. + oneof source { + // Label is generated AutoML model. This field stores the full resource + // name of the AutoML model. + // + // Format: + // `projects/{project-id}/locations/{location-id}/models/{model-id}` + string automl_model = 2; + } + + // Name of the label. + // + // When the label is generated from AutoML Text Classification model, this + // field represents the name of the category. + string name = 1; + + // Confidence score between 0 and 1 for label assignment. + float confidence = 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.v1beta2.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; + } + + // A page in a [Document][google.cloud.documentai.v1beta2.Document]. + message Page { + // Dimension for the page. + message Dimension { + // Page width. + float width = 1; + + // Page height. + float height = 2; + + // Dimension unit. + string unit = 3; + } + + // 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.v1beta2.Document.text]. + TextAnchor text_anchor = 1; + + // Confidence of the current [Layout][google.cloud.documentai.v1beta2.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.v1beta2.Document.Page.Layout]. + BoundingPoly bounding_poly = 3; + + // Detected orientation for the [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout]. + Orientation orientation = 4; + + // Optional. This is the identifier used by referencing [PageAnchor][google.cloud.documentai.v1beta2.Document.PageAnchor]s. + string id = 5 [(google.api.field_behavior) = OPTIONAL]; + } + + // A block has a set of lines (collected into paragraphs) that have a + // common line-spacing and orientation. + message Block { + // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [Block][google.cloud.documentai.v1beta2.Document.Page.Block]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + } + + // A collection of lines that a human would perceive as a paragraph. + message Paragraph { + // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1beta2.Document.Page.Paragraph]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + } + + // 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.v1beta2.Document.Page.Layout] for [Line][google.cloud.documentai.v1beta2.Document.Page.Line]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + } + + // A detected token. + message Token { + // Detected break at the end of a [Token][google.cloud.documentai.v1beta2.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.v1beta2.Document.Page.Layout] for [Token][google.cloud.documentai.v1beta2.Document.Page.Token]. + Layout layout = 1; + + // Detected break at the end of a [Token][google.cloud.documentai.v1beta2.Document.Page.Token]. + DetectedBreak detected_break = 2; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 3; + } + + // Detected non-text visual elements e.g. checkbox, signature etc. on the + // page. + message VisualElement { + // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1beta2.Document.Page.VisualElement]. + Layout layout = 1; + + // Type of the [VisualElement][google.cloud.documentai.v1beta2.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.v1beta2.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1beta2.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.v1beta2.Document.Page.Layout] for [Table][google.cloud.documentai.v1beta2.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; + } + + // A form field detected on the page. + message FormField { + // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta2.Document.Page.FormField] name. e.g. `Address`, `Email`, + // `Grand total`, `Phone number`, etc. + Layout field_name = 1; + + // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta2.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; + + // An internal field, created for Labeling UI to export key text. + string corrected_key_text = 6; + + // An internal field, created for Labeling UI to export value text. + string corrected_value_text = 7; + } + + // Detected language for a structural component. + message DetectedLanguage { + // The BCP-47 language code, such as "en-US" or "sr-Latn". For more + // information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 1; + + // Confidence of detected language. Range [0, 1]. + float confidence = 2; + } + + // 1-based index for current [Page][google.cloud.documentai.v1beta2.Document.Page] in a parent [Document][google.cloud.documentai.v1beta2.Document]. + // Useful when a page is taken out of a [Document][google.cloud.documentai.v1beta2.Document] for individual + // processing. + int32 page_number = 1; + + // Physical dimension of the page. + Dimension dimension = 2; + + // [Layout][google.cloud.documentai.v1beta2.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 phrase in the text that is a known entity type, such as a person, an + // organization, or location. + message Entity { + // Provenance of the entity. + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta2.Document.text]. + TextAnchor text_anchor = 1; + + // Entity type from a schema e.g. `Address`. + string type = 2; + + // Text value in the document e.g. `1600 Amphitheatre Pkwy`. + string mention_text = 3; + + // Deprecated. Use `id` field instead. + string mention_id = 4; + + // 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. Temporary field to store the bounding poly for short-term POCs. Used by + // the frontend only. Do not use before you talk to ybo@ and lukasr@. + BoundingPoly bounding_poly_for_demo_frontend = 8 [(google.api.field_behavior) = OPTIONAL]; + } + + // Relationship between [Entities][google.cloud.documentai.v1beta2.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.v1beta2.Document.text]. + message TextAnchor { + // A text segment in the [Document.text][google.cloud.documentai.v1beta2.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.v1beta2.Document.ShardInfo.text_offset] + message TextSegment { + // [TextSegment][google.cloud.documentai.v1beta2.Document.TextAnchor.TextSegment] start UTF-8 char index in the [Document.text][google.cloud.documentai.v1beta2.Document.text]. + int64 start_index = 1; + + // [TextSegment][google.cloud.documentai.v1beta2.Document.TextAnchor.TextSegment] half open end UTF-8 char index in the + // [Document.text][google.cloud.documentai.v1beta2.Document.text]. + int64 end_index = 2; + } + + // The text segments from the [Document.text][google.cloud.documentai.v1beta2.Document.text]. + repeated TextSegment text_segments = 1; + } + + // Referencing elements in [Document.pages][google.cloud.documentai.v1beta2.Document.pages]. + 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.v1beta2.Document.Page.blocks] element. + BLOCK = 1; + + // References a [Page.paragraphs][google.cloud.documentai.v1beta2.Document.Page.paragraphs] element. + PARAGRAPH = 2; + + // References a [Page.lines][google.cloud.documentai.v1beta2.Document.Page.lines] element. + LINE = 3; + + // References a [Page.tokens][google.cloud.documentai.v1beta2.Document.Page.tokens] element. + TOKEN = 4; + + // References a [Page.visual_elements][google.cloud.documentai.v1beta2.Document.Page.visual_elements] element. + VISUAL_ELEMENT = 5; + + // Refrrences a [Page.tables][google.cloud.documentai.v1beta2.Document.Page.tables] element. + TABLE = 6; + + // References a [Page.form_fields][google.cloud.documentai.v1beta2.Document.Page.form_fields] element. + FORM_FIELD = 7; + } + + // Required. Index into the [Document.pages][google.cloud.documentai.v1beta2.Document.pages] element + int64 page = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The type of the layout element that is being referenced. If not + // specified the whole page is assumed to be referenced. + LayoutType layout_type = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The [Page.Layout.id][google.cloud.documentai.v1beta2.Document.Page.Layout.id] on the page that this element + // references. If [LayoutRef.type][] is specified this id must also be + // specified. + string layout_id = 3 [(google.api.field_behavior) = OPTIONAL]; + } + + // One or more references to visual page elements + repeated PageRef page_refs = 1; + } + + // Original source document from the user. + oneof source { + // 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; + + // 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; + } + + // 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; + + // UTF-8 encoded text in reading order from the document. + string text = 4; + + // Styles for the [Document.text][google.cloud.documentai.v1beta2.Document.text]. + repeated Style text_styles = 5; + + // Visual page layout for the [Document][google.cloud.documentai.v1beta2.Document]. + repeated Page pages = 6; + + // A list of entities detected on [Document.text][google.cloud.documentai.v1beta2.Document.text]. For document shards, + // entities in this list may cross shard boundaries. + repeated Entity entities = 7; + + // Relationship among [Document.entities][google.cloud.documentai.v1beta2.Document.entities]. + repeated EntityRelation entity_relations = 8; + + // 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; + + // [Label][google.cloud.documentai.v1beta2.Document.Label]s for this document. + repeated Label labels = 11; + + // Any error that occurred while processing this document. + google.rpc.Status error = 10; +} diff --git a/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto b/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto new file mode 100644 index 000000000..137ba5e31 --- /dev/null +++ b/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto @@ -0,0 +1,346 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/cloud/documentai/v1beta2/document.proto"; +import "google/cloud/documentai/v1beta2/geometry.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta2;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProto"; +option java_package = "com.google.cloud.documentai.v1beta2"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta2"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta2"; + +// Service to parse structured information from unstructured or semi-structured +// documents using state-of-the-art Google AI such as natural language, +// computer vision, and translation. +service DocumentUnderstandingService { + option (google.api.default_host) = "documentai.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // LRO endpoint to batch process many documents. The output is written + // to Cloud Storage as JSON in the [Document] format. + rpc BatchProcessDocuments(BatchProcessDocumentsRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta2/{parent=projects/*/locations/*}/documents:batchProcess" + body: "*" + additional_bindings { + post: "/v1beta2/{parent=projects/*}/documents:batchProcess" + body: "*" + } + }; + option (google.api.method_signature) = "requests"; + option (google.longrunning.operation_info) = { + response_type: "BatchProcessDocumentsResponse" + metadata_type: "OperationMetadata" + }; + } + + // Processes a single document. + rpc ProcessDocument(ProcessDocumentRequest) returns (Document) { + option (google.api.http) = { + post: "/v1beta2/{parent=projects/*/locations/*}/documents:process" + body: "*" + additional_bindings { + post: "/v1beta2/{parent=projects/*}/documents:process" + body: "*" + } + }; + } +} + +// Request to batch process documents as an asynchronous operation. The output +// is written to Cloud Storage as JSON in the [Document] format. +message BatchProcessDocumentsRequest { + // Required. Individual requests for each document. + repeated ProcessDocumentRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; + + // Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no location is specified, a region will be chosen automatically. + string parent = 2; +} + +// Request to process one document. +message ProcessDocumentRequest { + // Target project and location to make a call. + // + // Format: `projects/{project-id}/locations/{location-id}`. + // + // If no location is specified, a region will be chosen automatically. + // This field is only populated when used in ProcessDocument method. + string parent = 9; + + // Required. Information about the input file. + InputConfig input_config = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The desired output location. This field is only needed in + // BatchProcessDocumentsRequest. + OutputConfig output_config = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Specifies a known document type for deeper structure detection. Valid + // values are currently "general" and "invoice". If not provided, "general"\ + // is used as default. If any other value is given, the request is rejected. + string document_type = 3; + + // Controls table extraction behavior. If not specified, the system will + // decide reasonable defaults. + TableExtractionParams table_extraction_params = 4; + + // Controls form extraction behavior. If not specified, the system will + // decide reasonable defaults. + FormExtractionParams form_extraction_params = 5; + + // Controls entity extraction behavior. If not specified, the system will + // decide reasonable defaults. + EntityExtractionParams entity_extraction_params = 6; + + // Controls OCR behavior. If not specified, the system will decide reasonable + // defaults. + OcrParams ocr_params = 7; + + // Controls AutoML model prediction behavior. AutoMlParams cannot be used + // together with other Params. + AutoMlParams automl_params = 8; +} + +// Response to an batch document processing request. This is returned in +// the LRO Operation after the operation is complete. +message BatchProcessDocumentsResponse { + // Responses for each individual document. + repeated ProcessDocumentResponse responses = 1; +} + +// Response to a single document processing request. +message ProcessDocumentResponse { + // Information about the input file. This is the same as the corresponding + // input config in the request. + InputConfig input_config = 1; + + // The output location of the parsed responses. The responses are written to + // this location as JSON-serialized `Document` objects. + OutputConfig output_config = 2; +} + +// Parameters to control Optical Character Recognition (OCR) behavior. +message OcrParams { + // List of languages to use for OCR. In most cases, an empty value + // yields the best results since it enables automatic language detection. For + // languages based on the Latin alphabet, setting `language_hints` is not + // needed. In rare cases, when the language of the text in the image is known, + // setting a hint will help get better results (although it will be a + // significant hindrance if the hint is wrong). Document processing returns an + // error if one or more of the specified languages is not one of the + // supported languages. + repeated string language_hints = 1; +} + +// Parameters to control table extraction behavior. +message TableExtractionParams { + // Whether to enable table extraction. + bool enabled = 1; + + // Optional. Table bounding box hints that can be provided to complex cases + // which our algorithm cannot locate the table(s) in. + repeated TableBoundHint table_bound_hints = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Table header hints. The extraction will bias towards producing + // these terms as table headers, which may improve accuracy. + repeated string header_hints = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Model version of the table extraction system. Default is "builtin/stable". + // Specify "builtin/latest" for the latest model. + string model_version = 4; +} + +// A hint for a table bounding box on the page for table parsing. +message TableBoundHint { + // Optional. Page number for multi-paged inputs this hint applies to. If not + // provided, this hint will apply to all pages by default. This value is + // 1-based. + int32 page_number = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Bounding box hint for a table on this page. The coordinates must be + // normalized to [0,1] and the bounding box must be an axis-aligned rectangle. + BoundingPoly bounding_box = 2; +} + +// Parameters to control form extraction behavior. +message FormExtractionParams { + // Whether to enable form extraction. + bool enabled = 1; + + // User can provide pairs of (key text, value type) to improve the parsing + // result. + // + // For example, if a document has a field called "Date" that holds a date + // value and a field called "Amount" that may hold either a currency value + // (e.g., "$500.00") or a simple number value (e.g., "20"), you could use the + // following hints: [ {"key": "Date", value_types: [ "DATE"]}, {"key": + // "Amount", "value_types": [ "PRICE", "NUMBER" ]} ] + // + // If the value type is unknown, but you want to provide hints for the keys, + // you can leave the value_types field blank. e.g. {"key": "Date", + // "value_types": []} + repeated KeyValuePairHint key_value_pair_hints = 2; + + // Model version of the form extraction system. Default is + // "builtin/stable". Specify "builtin/latest" for the latest model. + // For custom form models, specify: “custom/{model_name}". Model name + // format is "bucket_name/path/to/modeldir" corresponding to + // "gs://bucket_name/path/to/modeldir" where annotated examples are stored. + string model_version = 3; +} + +// User-provided hint for key value pair. +message KeyValuePairHint { + // The key text for the hint. + string key = 1; + + // Type of the value. This is case-insensitive, and could be one of: + // ADDRESS, LOCATION, ORGANIZATION, PERSON, PHONE_NUMBER, + // ID, NUMBER, EMAIL, PRICE, TERMS, DATE, NAME. Types not in this list will + // be ignored. + repeated string value_types = 2; +} + +// Parameters to control entity extraction behavior. +message EntityExtractionParams { + // Whether to enable entity extraction. + bool enabled = 1; + + // Model version of the entity extraction. Default is + // "builtin/stable". Specify "builtin/latest" for the latest model. + string model_version = 2; +} + +// Parameters to control AutoML model prediction behavior. +message AutoMlParams { + // Resource name of the AutoML model. + // + // Format: `projects/{project-id}/locations/{location-id}/models/{model-id}`. + string model = 1; +} + +// The desired input location and metadata. +message InputConfig { + // Required. + oneof source { + // The Google Cloud Storage location to read the input from. This must be a + // single file. + GcsSource gcs_source = 1; + + // Content in bytes, represented as a stream of bytes. + // Note: As with all `bytes` fields, proto buffer messages use a pure binary + // representation, whereas JSON representations use base64. + // + // This field only works for synchronous ProcessDocument method. + bytes contents = 3; + } + + // Required. Mimetype of the input. Current supported mimetypes are application/pdf, + // image/tiff, and image/gif. + // In addition, application/json type is supported for requests with + // [ProcessDocumentRequest.automl_params][google.cloud.documentai.v1beta2.ProcessDocumentRequest.automl_params] field set. The JSON file needs to + // be in [Document][google.cloud.documentai.v1beta2.Document] format. + string mime_type = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The desired output location and metadata. +message OutputConfig { + // Required. + oneof destination { + // The Google Cloud Storage location to write the output to. + GcsDestination gcs_destination = 1; + } + + // The max number of pages to include into each output Document shard JSON on + // Google Cloud Storage. + // + // The valid range is [1, 100]. If not specified, the default value is 20. + // + // For example, for one pdf file with 100 pages, 100 parsed pages will be + // produced. If `pages_per_shard` = 20, then 5 Document shard JSON files each + // containing 20 parsed pages will be written under the prefix + // [OutputConfig.gcs_destination.uri][] and suffix pages-x-to-y.json where + // x and y are 1-indexed page numbers. + // + // Example GCS outputs with 157 pages and pages_per_shard = 50: + // + // pages-001-to-050.json + // pages-051-to-100.json + // pages-101-to-150.json + // pages-151-to-157.json + int32 pages_per_shard = 2; +} + +// The Google Cloud Storage location where the input file will be read from. +message GcsSource { + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The Google Cloud Storage location where the output file will be written to. +message GcsDestination { + string uri = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Contains metadata for the BatchProcessDocuments operation. +message OperationMetadata { + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // Request is received. + ACCEPTED = 1; + + // Request operation is waiting for scheduling. + WAITING = 2; + + // Request is being processed. + RUNNING = 3; + + // The batch processing completed successfully. + SUCCEEDED = 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. + 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; +} diff --git a/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto b/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto new file mode 100644 index 000000000..6aff4db8c --- /dev/null +++ b/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto @@ -0,0 +1,57 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta2; + +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta2;documentai"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.documentai.v1beta2"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta2"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta2"; + +// 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. + 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. + 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/v1beta2/src/index.ts b/owl-bot-staging/v1beta2/src/index.ts new file mode 100644 index 000000000..446ae879d --- /dev/null +++ b/owl-bot-staging/v1beta2/src/index.ts @@ -0,0 +1,25 @@ +// 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. +// +// ** 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 v1beta2 from './v1beta2'; +const DocumentUnderstandingServiceClient = v1beta2.DocumentUnderstandingServiceClient; +type DocumentUnderstandingServiceClient = v1beta2.DocumentUnderstandingServiceClient; +export {v1beta2, DocumentUnderstandingServiceClient}; +export default {v1beta2, DocumentUnderstandingServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client.ts b/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client.ts new file mode 100644 index 000000000..d113355b6 --- /dev/null +++ b/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client.ts @@ -0,0 +1,516 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta2/document_understanding_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './document_understanding_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Service to parse structured information from unstructured or semi-structured + * documents using state-of-the-art Google AI such as natural language, + * computer vision, and translation. + * @class + * @memberof v1beta2 + */ +export class DocumentUnderstandingServiceClient { + 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}; + operationsClient: gax.OperationsClient; + documentUnderstandingServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DocumentUnderstandingServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DocumentUnderstandingServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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); + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const batchProcessDocumentsResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta2.BatchProcessDocumentsResponse') as gax.protobuf.Type; + const batchProcessDocumentsMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta2.OperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + batchProcessDocumentsResponse.decode.bind(batchProcessDocumentsResponse), + batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.documentai.v1beta2.DocumentUnderstandingService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.documentUnderstandingServiceStub) { + return this.documentUnderstandingServiceStub; + } + + // Put together the "service stub" for + // google.cloud.documentai.v1beta2.DocumentUnderstandingService. + this.documentUnderstandingServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.documentai.v1beta2.DocumentUnderstandingService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.documentai.v1beta2.DocumentUnderstandingService, + 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 documentUnderstandingServiceStubMethods = + ['batchProcessDocuments', 'processDocument']; + for (const methodName of documentUnderstandingServiceStubMethods) { + const callPromise = this.documentUnderstandingServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.documentUnderstandingServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'documentai.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 'documentai.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 -- + // ------------------- + processDocument( + request?: protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta2.IDocument, + protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|undefined, {}|undefined + ]>; + processDocument( + request: protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1beta2.IDocument, + protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|null|undefined, + {}|null|undefined>): void; + processDocument( + request: protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest, + callback: Callback< + protos.google.cloud.documentai.v1beta2.IDocument, + protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|null|undefined, + {}|null|undefined>): void; +/** + * Processes a single document. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no location is specified, a region will be chosen automatically. + * This field is only populated when used in ProcessDocument method. + * @param {google.cloud.documentai.v1beta2.InputConfig} request.inputConfig + * Required. Information about the input file. + * @param {google.cloud.documentai.v1beta2.OutputConfig} [request.outputConfig] + * Optional. The desired output location. This field is only needed in + * BatchProcessDocumentsRequest. + * @param {string} request.documentType + * Specifies a known document type for deeper structure detection. Valid + * values are currently "general" and "invoice". If not provided, "general"\ + * is used as default. If any other value is given, the request is rejected. + * @param {google.cloud.documentai.v1beta2.TableExtractionParams} request.tableExtractionParams + * Controls table extraction behavior. If not specified, the system will + * decide reasonable defaults. + * @param {google.cloud.documentai.v1beta2.FormExtractionParams} request.formExtractionParams + * Controls form extraction behavior. If not specified, the system will + * decide reasonable defaults. + * @param {google.cloud.documentai.v1beta2.EntityExtractionParams} request.entityExtractionParams + * Controls entity extraction behavior. If not specified, the system will + * decide reasonable defaults. + * @param {google.cloud.documentai.v1beta2.OcrParams} request.ocrParams + * Controls OCR behavior. If not specified, the system will decide reasonable + * defaults. + * @param {google.cloud.documentai.v1beta2.AutoMlParams} request.automlParams + * Controls AutoML model prediction behavior. AutoMlParams cannot be used + * together with other Params. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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.documentai.v1beta2.Document}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.processDocument(request); + */ + processDocument( + request?: protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1beta2.IDocument, + protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1beta2.IDocument, + protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1beta2.IDocument, + protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.processDocument(request, options, callback); + } + + batchProcessDocuments( + request?: protos.google.cloud.documentai.v1beta2.IBatchProcessDocumentsRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + batchProcessDocuments( + request: protos.google.cloud.documentai.v1beta2.IBatchProcessDocumentsRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + batchProcessDocuments( + request: protos.google.cloud.documentai.v1beta2.IBatchProcessDocumentsRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * LRO endpoint to batch process many documents. The output is written + * to Cloud Storage as JSON in the [Document] format. + * + * @param {Object} request + * The request object that will be sent. + * @param {number[]} request.requests + * Required. Individual requests for each document. + * @param {string} request.parent + * Target project and location to make a call. + * + * Format: `projects/{project-id}/locations/{location-id}`. + * + * If no location is specified, a region will be chosen automatically. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.batchProcessDocuments(request); + * const [response] = await operation.promise(); + */ + batchProcessDocuments( + request?: protos.google.cloud.documentai.v1beta2.IBatchProcessDocumentsRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.batchProcessDocuments(request, options, callback); + } +/** + * Check the status of the long running operation returned by `batchProcessDocuments()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkBatchProcessDocumentsProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkBatchProcessDocumentsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + + /** + * 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 { + this.initialize(); + if (!this._terminated) { + return this.documentUnderstandingServiceStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client_config.json b/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client_config.json new file mode 100644 index 000000000..1dea85e96 --- /dev/null +++ b/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client_config.json @@ -0,0 +1,36 @@ +{ + "interfaces": { + "google.cloud.documentai.v1beta2.DocumentUnderstandingService": { + "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": { + "BatchProcessDocuments": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ProcessDocument": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_proto_list.json b/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_proto_list.json new file mode 100644 index 000000000..ee1f3779a --- /dev/null +++ b/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/documentai/v1beta2/document.proto", + "../../protos/google/cloud/documentai/v1beta2/document_understanding.proto", + "../../protos/google/cloud/documentai/v1beta2/geometry.proto" +] diff --git a/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json b/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json new file mode 100644 index 000000000..49efed8a7 --- /dev/null +++ b/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json @@ -0,0 +1,43 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.documentai.v1beta2", + "libraryPackage": "@google-cloud/documentai", + "services": { + "DocumentUnderstandingService": { + "clients": { + "grpc": { + "libraryClient": "DocumentUnderstandingServiceClient", + "rpcs": { + "ProcessDocument": { + "methods": [ + "processDocument" + ] + }, + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentUnderstandingServiceClient", + "rpcs": { + "ProcessDocument": { + "methods": [ + "processDocument" + ] + }, + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/index.ts b/owl-bot-staging/v1beta2/src/v1beta2/index.ts new file mode 100644 index 000000000..1a00861f8 --- /dev/null +++ b/owl-bot-staging/v1beta2/src/v1beta2/index.ts @@ -0,0 +1,19 @@ +// 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. +// +// ** 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 {DocumentUnderstandingServiceClient} from './document_understanding_service_client'; diff --git a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js new file mode 100644 index 000000000..027cdf0f1 --- /dev/null +++ b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// 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. +// +// ** 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 documentai = require('@google-cloud/documentai'); + +function main() { + const documentUnderstandingServiceClient = new documentai.DocumentUnderstandingServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 000000000..ea46db1aa --- /dev/null +++ b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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. +// +// ** 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 {DocumentUnderstandingServiceClient} from '@google-cloud/documentai'; + +// check that the client class type name can be used +function doStuffWithDocumentUnderstandingServiceClient(client: DocumentUnderstandingServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const documentUnderstandingServiceClient = new DocumentUnderstandingServiceClient(); + doStuffWithDocumentUnderstandingServiceClient(documentUnderstandingServiceClient); +} + +main(); diff --git a/owl-bot-staging/v1beta2/system-test/install.ts b/owl-bot-staging/v1beta2/system-test/install.ts new file mode 100644 index 000000000..1f850b522 --- /dev/null +++ b/owl-bot-staging/v1beta2/system-test/install.ts @@ -0,0 +1,49 @@ +// 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. +// +// ** 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/v1beta2/test/gapic_document_understanding_service_v1beta2.ts b/owl-bot-staging/v1beta2/test/gapic_document_understanding_service_v1beta2.ts new file mode 100644 index 000000000..fb1d18335 --- /dev/null +++ b/owl-bot-staging/v1beta2/test/gapic_document_understanding_service_v1beta2.ts @@ -0,0 +1,364 @@ +// 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. +// +// ** 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 documentunderstandingserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1beta2.DocumentUnderstandingServiceClient', () => { + it('has servicePath', () => { + const servicePath = documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentUnderstandingServiceStub, undefined); + await client.initialize(); + assert(client.documentUnderstandingServiceStub); + }); + + it('has close method', () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + 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 documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + 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('processDocument', () => { + it('invokes processDocument without error', async () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.ProcessDocumentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.Document()); + client.innerApiCalls.processDocument = stubSimpleCall(expectedResponse); + const [response] = await client.processDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.processDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes processDocument without error using callback', async () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.ProcessDocumentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.Document()); + client.innerApiCalls.processDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.processDocument( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1beta2.IDocument|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.processDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes processDocument with error', async () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.ProcessDocumentRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.processDocument(request), expectedError); + assert((client.innerApiCalls.processDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('batchProcessDocuments', () => { + it('invokes batchProcessDocuments without error', async () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(expectedResponse); + const [operation] = await client.batchProcessDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchProcessDocuments without error using callback', async () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchProcessDocuments( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchProcessDocuments with call error', async () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.batchProcessDocuments(request), expectedError); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchProcessDocuments with LRO error', async () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.batchProcessDocuments(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkBatchProcessDocumentsProgress without error', async () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchProcessDocumentsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkBatchProcessDocumentsProgress with error', async () => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkBatchProcessDocumentsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); +}); diff --git a/owl-bot-staging/v1beta2/tsconfig.json b/owl-bot-staging/v1beta2/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/v1beta2/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/v1beta2/webpack.config.js b/owl-bot-staging/v1beta2/webpack.config.js new file mode 100644 index 000000000..c6fdde565 --- /dev/null +++ b/owl-bot-staging/v1beta2/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: 'DocumentUnderstandingService', + filename: './document-understanding-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/owl-bot-staging/v1beta3/.eslintignore b/owl-bot-staging/v1beta3/.eslintignore new file mode 100644 index 000000000..521dc25a2 --- /dev/null +++ b/owl-bot-staging/v1beta3/.eslintignore @@ -0,0 +1,6 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ diff --git a/owl-bot-staging/v1beta3/.eslintrc.json b/owl-bot-staging/v1beta3/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/v1beta3/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1beta3/.gitignore b/owl-bot-staging/v1beta3/.gitignore new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/owl-bot-staging/v1beta3/.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/v1beta3/.jsdoc.js b/owl-bot-staging/v1beta3/.jsdoc.js new file mode 100644 index 000000000..a00b08ce2 --- /dev/null +++ b/owl-bot-staging/v1beta3/.jsdoc.js @@ -0,0 +1,55 @@ +// 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. +// +// ** This file 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 2021 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/documentai', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1beta3/.mocharc.js b/owl-bot-staging/v1beta3/.mocharc.js new file mode 100644 index 000000000..50bc7f792 --- /dev/null +++ b/owl-bot-staging/v1beta3/.mocharc.js @@ -0,0 +1,33 @@ +// 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. +// +// ** 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/v1beta3/.prettierrc.js b/owl-bot-staging/v1beta3/.prettierrc.js new file mode 100644 index 000000000..84f4713a0 --- /dev/null +++ b/owl-bot-staging/v1beta3/.prettierrc.js @@ -0,0 +1,22 @@ +// 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. +// +// ** 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/v1beta3/README.md b/owl-bot-staging/v1beta3/README.md new file mode 100644 index 000000000..f41eef852 --- /dev/null +++ b/owl-bot-staging/v1beta3/README.md @@ -0,0 +1 @@ +Documentai: Nodejs Client diff --git a/owl-bot-staging/v1beta3/linkinator.config.json b/owl-bot-staging/v1beta3/linkinator.config.json new file mode 100644 index 000000000..29a223b6d --- /dev/null +++ b/owl-bot-staging/v1beta3/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1beta3/package.json b/owl-bot-staging/v1beta3/package.json new file mode 100644 index 000000000..57616ace7 --- /dev/null +++ b/owl-bot-staging/v1beta3/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/documentai", + "version": "0.1.0", + "description": "Documentai client for Node.js", + "repository": "googleapis/nodejs-documentai", + "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 documentai", + "documentai", + "document processor service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.19.0" + }, + "devDependencies": { + "@types/mocha": "^9.0.0", + "@types/node": "^14.17.3", + "@types/sinon": "^10.0.2", + "c8": "^7.7.3", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.0", + "jsdoc-region-tag": "^1.1.0", + "linkinator": "^2.13.6", + "mocha": "^9.0.2", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^11.1.1", + "ts-loader": "^9.2.3", + "typescript": "^4.3.4", + "webpack": "^5.39.1", + "webpack-cli": "^4.7.2" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto new file mode 100644 index 000000000..abba3ae19 --- /dev/null +++ b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto @@ -0,0 +1,730 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +import "google/api/field_behavior.proto"; +import "google/cloud/documentai/v1beta3/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"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.cloud.documentai.v1beta3"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; + +// Document represents the canonical document resource in Document Understanding +// AI. +// It is an interchange format that provides insights into documents and allows +// for collaboration between users and Document Understanding 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.v1beta3.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.v1beta3.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; + } + + // A page in a [Document][google.cloud.documentai.v1beta3.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.v1beta3.Document.text]. + TextAnchor text_anchor = 1; + + // Confidence of the current [Layout][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.Layout]. + BoundingPoly bounding_poly = 3; + + // Detected orientation for the [Layout][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.Layout] for [Block][google.cloud.documentai.v1beta3.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; + } + + // A collection of lines that a human would perceive as a paragraph. + message Paragraph { + // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1beta3.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; + } + + // 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.v1beta3.Document.Page.Layout] for [Line][google.cloud.documentai.v1beta3.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; + } + + // A detected token. + message Token { + // Detected break at the end of a [Token][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.Layout] for [Token][google.cloud.documentai.v1beta3.Document.Page.Token]. + Layout layout = 1; + + // Detected break at the end of a [Token][google.cloud.documentai.v1beta3.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; + } + + // Detected non-text visual elements e.g. checkbox, signature etc. on the + // page. + message VisualElement { + // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1beta3.Document.Page.VisualElement]. + Layout layout = 1; + + // Type of the [VisualElement][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.Layout] for [Table][google.cloud.documentai.v1beta3.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; + } + + // A form field detected on the page. + message FormField { + // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta3.Document.Page.FormField] name. e.g. `Address`, `Email`, + // `Grand total`, `Phone number`, etc. + Layout field_name = 1; + + // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta3.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; + + // The history of this annotation. + Provenance provenance = 8; + } + + // Detected language for a structural component. + message DetectedLanguage { + // The BCP-47 language code, such as "en-US" or "sr-Latn". For more + // information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 1; + + // Confidence of detected language. Range [0, 1]. + float confidence = 2; + } + + // 1-based index for current [Page][google.cloud.documentai.v1beta3.Document.Page] in a parent [Document][google.cloud.documentai.v1beta3.Document]. + // Useful when a page is taken out of a [Document][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.image]. + repeated Matrix transforms = 14; + + // Physical dimension of the page. + Dimension dimension = 2; + + // [Layout][google.cloud.documentai.v1beta3.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; + + // The history of this page. + Provenance provenance = 16; + } + + // A phrase in the text that is a known entity type, such as a person, an + // organization, or location. + message Entity { + // Parsed and normalized entity value. + message NormalizedValue { + // Structured entity value. Must match entity type defined in schema if + // known. If this field is present, the 'text' field is still 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; + } + + // Required. Normalized entity value stored as a string. This field is populated for + // supported document type (e.g. Invoice). For some entity types, one of + // respective 'structured_value' fields may also be populated. + // + // - 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) = REQUIRED]; + } + + // Optional. Provenance of the entity. + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta3.Document.text]. + TextAnchor text_anchor = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Entity type from a schema e.g. `Address`. + string type = 2; + + // Optional. Text value in the document 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.v1beta3.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.v1beta3.Document.text]. + message TextAnchor { + // A text segment in the [Document.text][google.cloud.documentai.v1beta3.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.v1beta3.Document.ShardInfo.text_offset] + message TextSegment { + // [TextSegment][google.cloud.documentai.v1beta3.Document.TextAnchor.TextSegment] start UTF-8 char index in the [Document.text][google.cloud.documentai.v1beta3.Document.text]. + int64 start_index = 1; + + // [TextSegment][google.cloud.documentai.v1beta3.Document.TextAnchor.TextSegment] half open end UTF-8 char index in the + // [Document.text][google.cloud.documentai.v1beta3.Document.text]. + int64 end_index = 2; + } + + // The text segments from the [Document.text][google.cloud.documentai.v1beta3.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. + string content = 2; + } + + // Referencing the visual context of the entity in the [Document.pages][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.blocks] element. + BLOCK = 1; + + // References a [Page.paragraphs][google.cloud.documentai.v1beta3.Document.Page.paragraphs] element. + PARAGRAPH = 2; + + // References a [Page.lines][google.cloud.documentai.v1beta3.Document.Page.lines] element. + LINE = 3; + + // References a [Page.tokens][google.cloud.documentai.v1beta3.Document.Page.tokens] element. + TOKEN = 4; + + // References a [Page.visual_elements][google.cloud.documentai.v1beta3.Document.Page.visual_elements] element. + VISUAL_ELEMENT = 5; + + // Refrrences a [Page.tables][google.cloud.documentai.v1beta3.Document.Page.tables] element. + TABLE = 6; + + // References a [Page.form_fields][google.cloud.documentai.v1beta3.Document.Page.form_fields] element. + FORM_FIELD = 7; + } + + // Required. Index into the [Document.pages][google.cloud.documentai.v1beta3.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.v1beta3.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 { + // Structure for referencing parent provenances. When an element replaces + // one of more other elements parent references identify the elements that + // are replaced. + message Parent { + // The index of the [Document.revisions] identifying the parent revision. + int32 revision = 1; + + // The index of the parent revisions corresponding collection of items + // (eg. list of entities, properties within entities, etc.) + 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. + OPERATION_TYPE_UNSPECIFIED = 0; + + // Add an element. Implicit if no `parents` are set for the provenance. + ADD = 1; + + // The element is removed. No `parents` should be set. + REMOVE = 2; + + // Explicitly replaces the element(s) identified by `parents`. + REPLACE = 3; + + // Element is requested for human review. + 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; + + // 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.v1beta3.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; + } + + // 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]; + + // Styles for the [Document.text][google.cloud.documentai.v1beta3.Document.text]. + repeated Style text_styles = 5; + + // Visual page layout for the [Document][google.cloud.documentai.v1beta3.Document]. + repeated Page pages = 6; + + // A list of entities detected on [Document.text][google.cloud.documentai.v1beta3.Document.text]. For document shards, + // entities in this list may cross shard boundaries. + repeated Entity entities = 7; + + // Relationship among [Document.entities][google.cloud.documentai.v1beta3.Document.entities]. + repeated EntityRelation entity_relations = 8; + + // A list of text corrections made to [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; + + // Revision history of this document. + repeated Revision revisions = 13; +} diff --git a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto new file mode 100644 index 000000000..d364d4aba --- /dev/null +++ b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto @@ -0,0 +1,86 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentIoProto"; +option java_package = "com.google.cloud.documentai.v1beta3"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; + +// 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]. + 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 Cloud Storage uri (a directory) of the output. + string gcs_uri = 1; + } + + // 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/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto new file mode 100644 index 000000000..e76a03164 --- /dev/null +++ b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto @@ -0,0 +1,572 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +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/v1beta3/document.proto"; +import "google/cloud/documentai/v1beta3/document_io.proto"; +import "google/cloud/documentai/v1beta3/operation_metadata.proto"; +import "google/cloud/documentai/v1beta3/processor.proto"; +import "google/cloud/documentai/v1beta3/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.V1Beta3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProcessorService"; +option java_package = "com.google.cloud.documentai.v1beta3"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; + +// (-- aip.dev/not-precedent: This is needed because we have references to +// these resources in our public API, but the resource management is not +// part of the public API (UI access only). So we have to define +// these resource here to avoid any "unable to find resources" error. --) +option (google.api.resource_definition) = { + type: "documentai.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; +option (google.api.resource_definition) = { + type: "documentai.googleapis.com/HumanReviewConfig" + pattern: "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" +}; + +// 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: "/v1beta3/{name=projects/*/locations/*/processors/*}: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: "/v1beta3/{name=projects/*/locations/*/processors/*}:batchProcess" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "BatchProcessResponse" + metadata_type: "BatchProcessMetadata" + }; + } + + // Fetches processor types. + rpc FetchProcessorTypes(FetchProcessorTypesRequest) returns (FetchProcessorTypesResponse) { + option (google.api.http) = { + get: "/v1beta3/{parent=projects/*/locations/*}:fetchProcessorTypes" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists all processors which belong to this project. + rpc ListProcessors(ListProcessorsRequest) returns (ListProcessorsResponse) { + option (google.api.http) = { + get: "/v1beta3/{parent=projects/*/locations/*}/processors" + }; + option (google.api.method_signature) = "parent"; + } + + // 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: "/v1beta3/{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: "/v1beta3/{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: "/v1beta3/{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: "/v1beta3/{name=projects/*/locations/*/processors/*}:disable" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "DisableProcessorResponse" + metadata_type: "DisableProcessorMetadata" + }; + } + + // 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: "/v1beta3/{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 processor resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; + + // The document payload, the [content] and [mime_type] fields must be set. + Document document = 2 [deprecated = true]; + + // Whether Human Review feature should be skipped for this request. Default to + // false. + bool skip_human_review = 3; +} + +// 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 name of the operation triggered by the processed document. If the human + // review process is not triggered, this field will be empty. It has the same + // response type and metadata as the long running operation returned by + // ReviewDocument method. + string human_review_operation = 2 [deprecated = true]; + + // The status of human review on the processed document. + HumanReviewStatus human_review_status = 3; +} + +// Request message for batch process document method. +message BatchProcessRequest { + // The message for input config in batch process. + message BatchInputConfig { + option deprecated = true; + + // The Cloud Storage location as the source of the document. + string gcs_source = 1; + + // Mimetype of the input. If the input is a raw document, the supported + // mimetypes are application/pdf, image/tiff, and image/gif. + // If the input is a [Document] proto, the type should be application/json. + string mime_type = 2; + } + + // The message for output config in batch process. + message BatchOutputConfig { + option deprecated = true; + + // The output Cloud Storage directory to put the processed documents. + string gcs_destination = 1; + } + + // Required. The processor resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; + + // The input config for each single document in the batch process. + repeated BatchInputConfig input_configs = 2 [deprecated = true]; + + // The overall output config for batch process. + BatchOutputConfig output_config = 3 [deprecated = true]; + + // 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 of the processing of 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 name of the operation triggered by the processed document. If the + // human review process is not triggered, this field will be empty. It has + // the same response type and metadata as the long running operation + // returned by ReviewDocument method. + string human_review_operation = 4 [deprecated = true]; + + // 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. + // 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 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 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. +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. +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 review document method. +// Next Id: 6. +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" + } + ]; + + // The document that needs human review. + Document document = 2 [deprecated = true]; + + // 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; +} + +// Response message for review document method. +message ReviewDocumentResponse { + // The Cloud Storage uri for the human reviewed document. + string gcs_destination = 1; +} + +// The long running operation metadata for review document method. +message ReviewDocumentOperationMetadata { + // 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; + } + + // Used only when Operation.done is false. + 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 basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} diff --git a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto new file mode 100644 index 000000000..91cd956ea --- /dev/null +++ b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto @@ -0,0 +1,57 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.documentai.v1beta3"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; + +// 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/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto new file mode 100644 index 000000000..1d8624e8f --- /dev/null +++ b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto @@ -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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.v1beta3; + +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; +option java_multiple_files = true; +option java_outer_classname = "OperationMetadataProto"; +option java_package = "com.google.cloud.documentai.v1beta3"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; + +// 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; + + // 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/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto new file mode 100644 index 000000000..61cd14a26 --- /dev/null +++ b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto @@ -0,0 +1,99 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/documentai/v1beta3/document_io.proto"; +import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProcessor"; +option java_package = "com.google.cloud.documentai.v1beta3"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; + +// The first-class citizen for DocumentAI. 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. + 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. + CREATING = 5; + + // The processor failed during creation. + 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. + 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; + + // 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/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto new file mode 100644 index 000000000..4bd4c16ab --- /dev/null +++ b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto @@ -0,0 +1,60 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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.v1beta3; + +import "google/api/resource.proto"; +import "google/api/annotations.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProcessorType"; +option java_package = "com.google.cloud.documentai.v1beta3"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; + +// 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. + string location_id = 1; + } + + // The resource name of the processor type. + string name = 1; + + // The type of the processor. + string type = 2; + + // The processor category. + string category = 3; + + // The locations in which this processor is available. + repeated LocationInfo available_locations = 4; + + // Whether the processor type allows creation. If yes, user can create a + // processor of this processor type. Otherwise, user needs to require for + // whitelisting. + bool allow_creation = 6; +} diff --git a/owl-bot-staging/v1beta3/src/index.ts b/owl-bot-staging/v1beta3/src/index.ts new file mode 100644 index 000000000..8bbd12507 --- /dev/null +++ b/owl-bot-staging/v1beta3/src/index.ts @@ -0,0 +1,25 @@ +// 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. +// +// ** 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 v1beta3 from './v1beta3'; +const DocumentProcessorServiceClient = v1beta3.DocumentProcessorServiceClient; +type DocumentProcessorServiceClient = v1beta3.DocumentProcessorServiceClient; +export {v1beta3, DocumentProcessorServiceClient}; +export default {v1beta3, DocumentProcessorServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client.ts b/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client.ts new file mode 100644 index 000000000..b5fe1a5ed --- /dev/null +++ b/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client.ts @@ -0,0 +1,1502 @@ +// 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1beta3/document_processor_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './document_processor_service_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * 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. + * @class + * @memberof v1beta3 + */ +export class DocumentProcessorServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + documentProcessorServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DocumentProcessorServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DocumentProcessorServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set 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 = { + humanReviewConfigPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + processorPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/processors/{processor}' + ), + processorTypePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/processorTypes/{processor_type}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listProcessors: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processors') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + + this.operationsClient = this._gaxModule.lro({ + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }).operationsClient(opts); + const batchProcessDocumentsResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.BatchProcessResponse') as gax.protobuf.Type; + const batchProcessDocumentsMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.BatchProcessMetadata') as gax.protobuf.Type; + const deleteProcessorResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteProcessorMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.DeleteProcessorMetadata') as gax.protobuf.Type; + const enableProcessorResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.EnableProcessorResponse') as gax.protobuf.Type; + const enableProcessorMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.EnableProcessorMetadata') as gax.protobuf.Type; + const disableProcessorResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.DisableProcessorResponse') as gax.protobuf.Type; + const disableProcessorMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.DisableProcessorMetadata') as gax.protobuf.Type; + const reviewDocumentResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.ReviewDocumentResponse') as gax.protobuf.Type; + const reviewDocumentMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + batchProcessDocumentsResponse.decode.bind(batchProcessDocumentsResponse), + batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata)), + deleteProcessor: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteProcessorResponse.decode.bind(deleteProcessorResponse), + deleteProcessorMetadata.decode.bind(deleteProcessorMetadata)), + enableProcessor: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + enableProcessorResponse.decode.bind(enableProcessorResponse), + enableProcessorMetadata.decode.bind(enableProcessorMetadata)), + disableProcessor: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + disableProcessorResponse.decode.bind(disableProcessorResponse), + disableProcessorMetadata.decode.bind(disableProcessorMetadata)), + reviewDocument: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + reviewDocumentResponse.decode.bind(reviewDocumentResponse), + reviewDocumentMetadata.decode.bind(reviewDocumentMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.documentai.v1beta3.DocumentProcessorService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.documentProcessorServiceStub) { + return this.documentProcessorServiceStub; + } + + // Put together the "service stub" for + // google.cloud.documentai.v1beta3.DocumentProcessorService. + this.documentProcessorServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.documentai.v1beta3.DocumentProcessorService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.documentai.v1beta3.DocumentProcessorService, + 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 documentProcessorServiceStubMethods = + ['processDocument', 'batchProcessDocuments', 'fetchProcessorTypes', 'listProcessors', 'createProcessor', 'deleteProcessor', 'enableProcessor', 'disableProcessor', 'reviewDocument']; + for (const methodName of documentProcessorServiceStubMethods) { + const callPromise = this.documentProcessorServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.documentProcessorServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'documentai.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 'documentai.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 -- + // ------------------- + processDocument( + request?: protos.google.cloud.documentai.v1beta3.IProcessRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessResponse, + protos.google.cloud.documentai.v1beta3.IProcessRequest|undefined, {}|undefined + ]>; + processDocument( + request: protos.google.cloud.documentai.v1beta3.IProcessRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IProcessResponse, + protos.google.cloud.documentai.v1beta3.IProcessRequest|null|undefined, + {}|null|undefined>): void; + processDocument( + request: protos.google.cloud.documentai.v1beta3.IProcessRequest, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IProcessResponse, + protos.google.cloud.documentai.v1beta3.IProcessRequest|null|undefined, + {}|null|undefined>): void; +/** + * Processes a single document. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.documentai.v1beta3.Document} request.inlineDocument + * An inline document proto. + * @param {google.cloud.documentai.v1beta3.RawDocument} request.rawDocument + * A raw document content (bytes). + * @param {string} request.name + * Required. The processor resource name. + * @param {google.cloud.documentai.v1beta3.Document} request.document + * The document payload, the [content] and [mime_type] fields must be set. + * @param {boolean} request.skipHumanReview + * Whether Human Review feature should be skipped for this request. Default to + * false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProcessResponse]{@link google.cloud.documentai.v1beta3.ProcessResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.processDocument(request); + */ + processDocument( + request?: protos.google.cloud.documentai.v1beta3.IProcessRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1beta3.IProcessResponse, + protos.google.cloud.documentai.v1beta3.IProcessRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1beta3.IProcessResponse, + protos.google.cloud.documentai.v1beta3.IProcessRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessResponse, + protos.google.cloud.documentai.v1beta3.IProcessRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.processDocument(request, options, callback); + } + fetchProcessorTypes( + request?: protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|undefined, {}|undefined + ]>; + fetchProcessorTypes( + request: protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|null|undefined, + {}|null|undefined>): void; + fetchProcessorTypes( + request: protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|null|undefined, + {}|null|undefined>): void; +/** + * Fetches processor types. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project of processor type to list. + * Format: projects/{project}/locations/{location} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [FetchProcessorTypesResponse]{@link google.cloud.documentai.v1beta3.FetchProcessorTypesResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.fetchProcessorTypes(request); + */ + fetchProcessorTypes( + request?: protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.fetchProcessorTypes(request, options, callback); + } + createProcessor( + request?: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|undefined, {}|undefined + ]>; + createProcessor( + request: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|null|undefined, + {}|null|undefined>): void; + createProcessor( + request: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|null|undefined, + {}|null|undefined>): void; +/** + * Creates a processor from the type processor that the user chose. + * The processor will be at "ENABLED" state by default after its creation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) under which to create the processor. + * Format: projects/{project}/locations/{location} + * @param {google.cloud.documentai.v1beta3.Processor} request.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. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Processor]{@link google.cloud.documentai.v1beta3.Processor}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createProcessor(request); + */ + createProcessor( + request?: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createProcessor(request, options, callback); + } + + batchProcessDocuments( + request?: protos.google.cloud.documentai.v1beta3.IBatchProcessRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + batchProcessDocuments( + request: protos.google.cloud.documentai.v1beta3.IBatchProcessRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + batchProcessDocuments( + request: protos.google.cloud.documentai.v1beta3.IBatchProcessRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * LRO endpoint to batch process many documents. The output is written + * to Cloud Storage as JSON in the [Document] format. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor resource name. + * @param {number[]} request.inputConfigs + * The input config for each single document in the batch process. + * @param {google.cloud.documentai.v1beta3.BatchProcessRequest.BatchOutputConfig} request.outputConfig + * The overall output config for batch process. + * @param {google.cloud.documentai.v1beta3.BatchDocumentsInputConfig} request.inputDocuments + * The input documents for batch process. + * @param {google.cloud.documentai.v1beta3.DocumentOutputConfig} request.documentOutputConfig + * The overall output config for batch process. + * @param {boolean} request.skipHumanReview + * Whether Human Review feature should be skipped for this request. Default to + * false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.batchProcessDocuments(request); + * const [response] = await operation.promise(); + */ + batchProcessDocuments( + request?: protos.google.cloud.documentai.v1beta3.IBatchProcessRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.batchProcessDocuments(request, options, callback); + } +/** + * Check the status of the long running operation returned by `batchProcessDocuments()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkBatchProcessDocumentsProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkBatchProcessDocumentsProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + deleteProcessor( + request?: protos.google.cloud.documentai.v1beta3.IDeleteProcessorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteProcessor( + request: protos.google.cloud.documentai.v1beta3.IDeleteProcessorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProcessor( + request: protos.google.cloud.documentai.v1beta3.IDeleteProcessorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Deletes the processor, unloads all deployed model artifacts if it was + * enabled and then deletes all artifacts associated with this processor. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor resource name to be deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.deleteProcessor(request); + * const [response] = await operation.promise(); + */ + deleteProcessor( + request?: protos.google.cloud.documentai.v1beta3.IDeleteProcessorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProcessor(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteProcessor()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkDeleteProcessorProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkDeleteProcessorProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.deleteProcessor, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + enableProcessor( + request?: protos.google.cloud.documentai.v1beta3.IEnableProcessorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + enableProcessor( + request: protos.google.cloud.documentai.v1beta3.IEnableProcessorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + enableProcessor( + request: protos.google.cloud.documentai.v1beta3.IEnableProcessorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Enables a processor + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor resource name to be enabled. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.enableProcessor(request); + * const [response] = await operation.promise(); + */ + enableProcessor( + request?: protos.google.cloud.documentai.v1beta3.IEnableProcessorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.enableProcessor(request, options, callback); + } +/** + * Check the status of the long running operation returned by `enableProcessor()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkEnableProcessorProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkEnableProcessorProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.enableProcessor, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + disableProcessor( + request?: protos.google.cloud.documentai.v1beta3.IDisableProcessorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + disableProcessor( + request: protos.google.cloud.documentai.v1beta3.IDisableProcessorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + disableProcessor( + request: protos.google.cloud.documentai.v1beta3.IDisableProcessorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Disables a processor + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor resource name to be disabled. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.disableProcessor(request); + * const [response] = await operation.promise(); + */ + disableProcessor( + request?: protos.google.cloud.documentai.v1beta3.IDisableProcessorRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.disableProcessor(request, options, callback); + } +/** + * Check the status of the long running operation returned by `disableProcessor()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkDisableProcessorProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkDisableProcessorProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.disableProcessor, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + reviewDocument( + request?: protos.google.cloud.documentai.v1beta3.IReviewDocumentRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + reviewDocument( + request: protos.google.cloud.documentai.v1beta3.IReviewDocumentRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + reviewDocument( + request: protos.google.cloud.documentai.v1beta3.IReviewDocumentRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; +/** + * Send a document for Human Review. The input document should be processed by + * the specified processor. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.documentai.v1beta3.Document} request.inlineDocument + * An inline document proto. + * @param {string} request.humanReviewConfig + * Required. The resource name of the HumanReviewConfig that the document will be + * reviewed with. + * @param {google.cloud.documentai.v1beta3.Document} request.document + * The document that needs human review. + * @param {boolean} request.enableSchemaValidation + * Whether the validation should be performed on the ad-hoc review request. + * @param {google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority} request.priority + * The priority of the human review task. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.reviewDocument(request); + * const [response] = await operation.promise(); + */ + reviewDocument( + request?: protos.google.cloud.documentai.v1beta3.IReviewDocumentRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'human_review_config': request.humanReviewConfig || '', + }); + this.initialize(); + return this.innerApiCalls.reviewDocument(request, options, callback); + } +/** + * Check the status of the long running operation returned by `reviewDocument()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkReviewDocumentProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkReviewDocumentProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.reviewDocument, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + listProcessors( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessor[], + protos.google.cloud.documentai.v1beta3.IListProcessorsRequest|null, + protos.google.cloud.documentai.v1beta3.IListProcessorsResponse + ]>; + listProcessors( + request: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessor>): void; + listProcessors( + request: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, + callback: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessor>): void; +/** + * Lists all processors which belong to this project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) which owns this collection of Processors. + * Format: projects/{project}/locations/{location} + * @param {number} request.pageSize + * 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. + * @param {string} request.pageToken + * We will return the processors sorted by creation time. The page token + * will point to the next processor. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [Processor]{@link google.cloud.documentai.v1beta3.Processor}. + * 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 `listProcessorsAsync()` + * 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. + */ + listProcessors( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessor>, + callback?: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessor>): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessor[], + protos.google.cloud.documentai.v1beta3.IListProcessorsRequest|null, + protos.google.cloud.documentai.v1beta3.IListProcessorsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listProcessors(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 (project and location) which owns this collection of Processors. + * Format: projects/{project}/locations/{location} + * @param {number} request.pageSize + * 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. + * @param {string} request.pageToken + * We will return the processors sorted by creation time. The page token + * will point to the next processor. + * @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 [Processor]{@link google.cloud.documentai.v1beta3.Processor} 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 `listProcessorsAsync()` + * 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. + */ + listProcessorsStream( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listProcessors.createStream( + this.innerApiCalls.listProcessors as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProcessors`, 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 (project and location) which owns this collection of Processors. + * Format: projects/{project}/locations/{location} + * @param {number} request.pageSize + * 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. + * @param {string} request.pageToken + * We will return the processors sorted by creation time. The page token + * will point to the next processor. + * @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 + * [Processor]{@link google.cloud.documentai.v1beta3.Processor}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listProcessorsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listProcessorsAsync( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listProcessors.asyncIterate( + this.innerApiCalls['listProcessors'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified humanReviewConfig resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} processor + * @returns {string} Resource name string. + */ + humanReviewConfigPath(project:string,location:string,processor:string) { + return this.pathTemplates.humanReviewConfigPathTemplate.render({ + project: project, + location: location, + processor: processor, + }); + } + + /** + * Parse the project from HumanReviewConfig resource. + * + * @param {string} humanReviewConfigName + * A fully-qualified path representing HumanReviewConfig resource. + * @returns {string} A string representing the project. + */ + matchProjectFromHumanReviewConfigName(humanReviewConfigName: string) { + return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).project; + } + + /** + * Parse the location from HumanReviewConfig resource. + * + * @param {string} humanReviewConfigName + * A fully-qualified path representing HumanReviewConfig resource. + * @returns {string} A string representing the location. + */ + matchLocationFromHumanReviewConfigName(humanReviewConfigName: string) { + return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).location; + } + + /** + * Parse the processor from HumanReviewConfig resource. + * + * @param {string} humanReviewConfigName + * A fully-qualified path representing HumanReviewConfig resource. + * @returns {string} A string representing the processor. + */ + matchProcessorFromHumanReviewConfigName(humanReviewConfigName: string) { + return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).processor; + } + + /** + * 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 processor resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} processor + * @returns {string} Resource name string. + */ + processorPath(project:string,location:string,processor:string) { + return this.pathTemplates.processorPathTemplate.render({ + project: project, + location: location, + processor: processor, + }); + } + + /** + * Parse the project from Processor resource. + * + * @param {string} processorName + * A fully-qualified path representing Processor resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProcessorName(processorName: string) { + return this.pathTemplates.processorPathTemplate.match(processorName).project; + } + + /** + * Parse the location from Processor resource. + * + * @param {string} processorName + * A fully-qualified path representing Processor resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProcessorName(processorName: string) { + return this.pathTemplates.processorPathTemplate.match(processorName).location; + } + + /** + * Parse the processor from Processor resource. + * + * @param {string} processorName + * A fully-qualified path representing Processor resource. + * @returns {string} A string representing the processor. + */ + matchProcessorFromProcessorName(processorName: string) { + return this.pathTemplates.processorPathTemplate.match(processorName).processor; + } + + /** + * Return a fully-qualified processorType resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} processor_type + * @returns {string} Resource name string. + */ + processorTypePath(project:string,location:string,processorType:string) { + return this.pathTemplates.processorTypePathTemplate.render({ + project: project, + location: location, + processor_type: processorType, + }); + } + + /** + * Parse the project from ProcessorType resource. + * + * @param {string} processorTypeName + * A fully-qualified path representing ProcessorType resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProcessorTypeName(processorTypeName: string) { + return this.pathTemplates.processorTypePathTemplate.match(processorTypeName).project; + } + + /** + * Parse the location from ProcessorType resource. + * + * @param {string} processorTypeName + * A fully-qualified path representing ProcessorType resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProcessorTypeName(processorTypeName: string) { + return this.pathTemplates.processorTypePathTemplate.match(processorTypeName).location; + } + + /** + * Parse the processor_type from ProcessorType resource. + * + * @param {string} processorTypeName + * A fully-qualified path representing ProcessorType resource. + * @returns {string} A string representing the processor_type. + */ + matchProcessorTypeFromProcessorTypeName(processorTypeName: string) { + return this.pathTemplates.processorTypePathTemplate.match(processorTypeName).processor_type; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.documentProcessorServiceStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client_config.json b/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client_config.json new file mode 100644 index 000000000..8fde58b8d --- /dev/null +++ b/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client_config.json @@ -0,0 +1,65 @@ +{ + "interfaces": { + "google.cloud.documentai.v1beta3.DocumentProcessorService": { + "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": { + "ProcessDocument": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BatchProcessDocuments": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "FetchProcessorTypes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProcessors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateProcessor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProcessor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "EnableProcessor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DisableProcessor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ReviewDocument": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_proto_list.json b/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_proto_list.json new file mode 100644 index 000000000..e6cd85900 --- /dev/null +++ b/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_proto_list.json @@ -0,0 +1,9 @@ +[ + "../../protos/google/cloud/documentai/v1beta3/document.proto", + "../../protos/google/cloud/documentai/v1beta3/document_io.proto", + "../../protos/google/cloud/documentai/v1beta3/document_processor_service.proto", + "../../protos/google/cloud/documentai/v1beta3/geometry.proto", + "../../protos/google/cloud/documentai/v1beta3/operation_metadata.proto", + "../../protos/google/cloud/documentai/v1beta3/processor.proto", + "../../protos/google/cloud/documentai/v1beta3/processor_type.proto" +] diff --git a/owl-bot-staging/v1beta3/src/v1beta3/gapic_metadata.json b/owl-bot-staging/v1beta3/src/v1beta3/gapic_metadata.json new file mode 100644 index 000000000..791a44e4d --- /dev/null +++ b/owl-bot-staging/v1beta3/src/v1beta3/gapic_metadata.json @@ -0,0 +1,117 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.documentai.v1beta3", + "libraryPackage": "@google-cloud/documentai", + "services": { + "DocumentProcessorService": { + "clients": { + "grpc": { + "libraryClient": "DocumentProcessorServiceClient", + "rpcs": { + "ProcessDocument": { + "methods": [ + "processDocument" + ] + }, + "FetchProcessorTypes": { + "methods": [ + "fetchProcessorTypes" + ] + }, + "CreateProcessor": { + "methods": [ + "createProcessor" + ] + }, + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + }, + "DeleteProcessor": { + "methods": [ + "deleteProcessor" + ] + }, + "EnableProcessor": { + "methods": [ + "enableProcessor" + ] + }, + "DisableProcessor": { + "methods": [ + "disableProcessor" + ] + }, + "ReviewDocument": { + "methods": [ + "reviewDocument" + ] + }, + "ListProcessors": { + "methods": [ + "listProcessors", + "listProcessorsStream", + "listProcessorsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentProcessorServiceClient", + "rpcs": { + "ProcessDocument": { + "methods": [ + "processDocument" + ] + }, + "FetchProcessorTypes": { + "methods": [ + "fetchProcessorTypes" + ] + }, + "CreateProcessor": { + "methods": [ + "createProcessor" + ] + }, + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + }, + "DeleteProcessor": { + "methods": [ + "deleteProcessor" + ] + }, + "EnableProcessor": { + "methods": [ + "enableProcessor" + ] + }, + "DisableProcessor": { + "methods": [ + "disableProcessor" + ] + }, + "ReviewDocument": { + "methods": [ + "reviewDocument" + ] + }, + "ListProcessors": { + "methods": [ + "listProcessors", + "listProcessorsStream", + "listProcessorsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1beta3/src/v1beta3/index.ts b/owl-bot-staging/v1beta3/src/v1beta3/index.ts new file mode 100644 index 000000000..2f6c91a42 --- /dev/null +++ b/owl-bot-staging/v1beta3/src/v1beta3/index.ts @@ -0,0 +1,19 @@ +// 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. +// +// ** 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 {DocumentProcessorServiceClient} from './document_processor_service_client'; diff --git a/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.js new file mode 100644 index 000000000..7a0b0174d --- /dev/null +++ b/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// 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. +// +// ** 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 documentai = require('@google-cloud/documentai'); + +function main() { + const documentProcessorServiceClient = new documentai.DocumentProcessorServiceClient(); +} + +main(); diff --git a/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.ts new file mode 100644 index 000000000..2bccab99e --- /dev/null +++ b/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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. +// +// ** 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 {DocumentProcessorServiceClient} from '@google-cloud/documentai'; + +// check that the client class type name can be used +function doStuffWithDocumentProcessorServiceClient(client: DocumentProcessorServiceClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const documentProcessorServiceClient = new DocumentProcessorServiceClient(); + doStuffWithDocumentProcessorServiceClient(documentProcessorServiceClient); +} + +main(); diff --git a/owl-bot-staging/v1beta3/system-test/install.ts b/owl-bot-staging/v1beta3/system-test/install.ts new file mode 100644 index 000000000..1f850b522 --- /dev/null +++ b/owl-bot-staging/v1beta3/system-test/install.ts @@ -0,0 +1,49 @@ +// 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. +// +// ** 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/v1beta3/test/gapic_document_processor_service_v1beta3.ts b/owl-bot-staging/v1beta3/test/gapic_document_processor_service_v1beta3.ts new file mode 100644 index 000000000..fa9f9b3ae --- /dev/null +++ b/owl-bot-staging/v1beta3/test/gapic_document_processor_service_v1beta3.ts @@ -0,0 +1,1587 @@ +// 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. +// +// ** 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 documentprocessorserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta3.DocumentProcessorServiceClient', () => { + it('has servicePath', () => { + const servicePath = documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentProcessorServiceStub, undefined); + await client.initialize(); + assert(client.documentProcessorServiceStub); + }); + + it('has close method', () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + 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 documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + 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('processDocument', () => { + it('invokes processDocument without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessResponse()); + client.innerApiCalls.processDocument = stubSimpleCall(expectedResponse); + const [response] = await client.processDocument(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.processDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes processDocument without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessResponse()); + client.innerApiCalls.processDocument = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.processDocument( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.processDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes processDocument with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.processDocument(request), expectedError); + assert((client.innerApiCalls.processDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('fetchProcessorTypes', () => { + it('invokes fetchProcessorTypes without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.FetchProcessorTypesResponse()); + client.innerApiCalls.fetchProcessorTypes = stubSimpleCall(expectedResponse); + const [response] = await client.fetchProcessorTypes(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes fetchProcessorTypes without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.FetchProcessorTypesResponse()); + client.innerApiCalls.fetchProcessorTypes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.fetchProcessorTypes( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes fetchProcessorTypes with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.fetchProcessorTypes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.fetchProcessorTypes(request), expectedError); + assert((client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('createProcessor', () => { + it('invokes createProcessor without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.CreateProcessorRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()); + client.innerApiCalls.createProcessor = stubSimpleCall(expectedResponse); + const [response] = await client.createProcessor(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProcessor without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.CreateProcessorRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()); + client.innerApiCalls.createProcessor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProcessor( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessor|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProcessor with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.CreateProcessorRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createProcessor = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProcessor(request), expectedError); + assert((client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + + describe('batchProcessDocuments', () => { + it('invokes batchProcessDocuments without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.BatchProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(expectedResponse); + const [operation] = await client.batchProcessDocuments(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchProcessDocuments without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.BatchProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchProcessDocuments( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes batchProcessDocuments with call error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.BatchProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.batchProcessDocuments(request), expectedError); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes batchProcessDocuments with LRO error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.BatchProcessRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.batchProcessDocuments(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkBatchProcessDocumentsProgress without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchProcessDocumentsProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkBatchProcessDocumentsProgress with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkBatchProcessDocumentsProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteProcessor', () => { + it('invokes deleteProcessor without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DeleteProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteProcessor = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteProcessor(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProcessor without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DeleteProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteProcessor = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProcessor( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProcessor with call error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DeleteProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteProcessor(request), expectedError); + assert((client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProcessor with LRO error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DeleteProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteProcessor(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteProcessorProgress without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteProcessorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteProcessorProgress with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteProcessorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('enableProcessor', () => { + it('invokes enableProcessor without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.EnableProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.enableProcessor = stubLongRunningCall(expectedResponse); + const [operation] = await client.enableProcessor(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes enableProcessor without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.EnableProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.enableProcessor = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.enableProcessor( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes enableProcessor with call error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.EnableProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.enableProcessor(request), expectedError); + assert((client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes enableProcessor with LRO error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.EnableProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.enableProcessor(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkEnableProcessorProgress without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkEnableProcessorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkEnableProcessorProgress with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkEnableProcessorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('disableProcessor', () => { + it('invokes disableProcessor without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DisableProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.disableProcessor = stubLongRunningCall(expectedResponse); + const [operation] = await client.disableProcessor(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes disableProcessor without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DisableProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.disableProcessor = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.disableProcessor( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes disableProcessor with call error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DisableProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.disableProcessor(request), expectedError); + assert((client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes disableProcessor with LRO error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DisableProcessorRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.disableProcessor(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDisableProcessorProgress without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDisableProcessorProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDisableProcessorProgress with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDisableProcessorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('reviewDocument', () => { + it('invokes reviewDocument without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ReviewDocumentRequest()); + request.humanReviewConfig = ''; + const expectedHeaderRequestParams = "human_review_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.reviewDocument = stubLongRunningCall(expectedResponse); + const [operation] = await client.reviewDocument(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes reviewDocument without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ReviewDocumentRequest()); + request.humanReviewConfig = ''; + const expectedHeaderRequestParams = "human_review_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.reviewDocument = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reviewDocument( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes reviewDocument with call error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ReviewDocumentRequest()); + request.humanReviewConfig = ''; + const expectedHeaderRequestParams = "human_review_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.reviewDocument(request), expectedError); + assert((client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes reviewDocument with LRO error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ReviewDocumentRequest()); + request.humanReviewConfig = ''; + const expectedHeaderRequestParams = "human_review_config="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.reviewDocument(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkReviewDocumentProgress without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkReviewDocumentProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkReviewDocumentProgress with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkReviewDocumentProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProcessors', () => { + it('invokes listProcessors without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + ]; + client.innerApiCalls.listProcessors = stubSimpleCall(expectedResponse); + const [response] = await client.listProcessors(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProcessors without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + ]; + client.innerApiCalls.listProcessors = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProcessors( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessor[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProcessors with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listProcessors = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProcessors(request), expectedError); + assert((client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProcessorsStream without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + ]; + client.descriptors.page.listProcessors.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProcessorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1beta3.Processor[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1beta3.Processor) => { + 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.listProcessors.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProcessors, request)); + assert.strictEqual( + (client.descriptors.page.listProcessors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listProcessorsStream with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listProcessors.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProcessorsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1beta3.Processor[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1beta3.Processor) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProcessors.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProcessors, request)); + assert.strictEqual( + (client.descriptors.page.listProcessors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProcessors without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), + ]; + client.descriptors.page.listProcessors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.documentai.v1beta3.IProcessor[] = []; + const iterable = client.listProcessorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listProcessors with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listProcessors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProcessorsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.documentai.v1beta3.IProcessor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('humanReviewConfig', () => { + const fakePath = "/rendered/path/humanReviewConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + processor: "processorValue", + }; + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.humanReviewConfigPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.humanReviewConfigPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('humanReviewConfigPath', () => { + const result = client.humanReviewConfigPath("projectValue", "locationValue", "processorValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.humanReviewConfigPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromHumanReviewConfigName', () => { + const result = client.matchProjectFromHumanReviewConfigName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromHumanReviewConfigName', () => { + const result = client.matchLocationFromHumanReviewConfigName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorFromHumanReviewConfigName', () => { + const result = client.matchProcessorFromHumanReviewConfigName(fakePath); + assert.strictEqual(result, "processorValue"); + assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + 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('processor', () => { + const fakePath = "/rendered/path/processor"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + processor: "processorValue", + }; + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.processorPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.processorPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('processorPath', () => { + const result = client.processorPath("projectValue", "locationValue", "processorValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.processorPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProcessorName', () => { + const result = client.matchProjectFromProcessorName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.processorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProcessorName', () => { + const result = client.matchLocationFromProcessorName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.processorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorFromProcessorName', () => { + const result = client.matchProcessorFromProcessorName(fakePath); + assert.strictEqual(result, "processorValue"); + assert((client.pathTemplates.processorPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('processorType', () => { + const fakePath = "/rendered/path/processorType"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + processor_type: "processorTypeValue", + }; + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.processorTypePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.processorTypePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('processorTypePath', () => { + const result = client.processorTypePath("projectValue", "locationValue", "processorTypeValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.processorTypePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProcessorTypeName', () => { + const result = client.matchProjectFromProcessorTypeName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.processorTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProcessorTypeName', () => { + const result = client.matchLocationFromProcessorTypeName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.processorTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorTypeFromProcessorTypeName', () => { + const result = client.matchProcessorTypeFromProcessorTypeName(fakePath); + assert.strictEqual(result, "processorTypeValue"); + assert((client.pathTemplates.processorTypePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1beta3/tsconfig.json b/owl-bot-staging/v1beta3/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/v1beta3/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/v1beta3/webpack.config.js b/owl-bot-staging/v1beta3/webpack.config.js new file mode 100644 index 000000000..fc7bef574 --- /dev/null +++ b/owl-bot-staging/v1beta3/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: 'DocumentProcessorService', + filename: './document-processor-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 6450df0bac4c6697624921e8db2295c482d89910 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 11 Aug 2021 22:48:35 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= 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 --- owl-bot-staging/v1/.eslintignore | 6 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 10 - owl-bot-staging/v1/package.json | 64 - .../google/cloud/documentai/v1/document.proto | 730 -------- .../cloud/documentai/v1/document_io.proto | 86 - .../v1/document_processor_service.proto | 301 ---- .../google/cloud/documentai/v1/geometry.proto | 57 - .../documentai/v1/operation_metadata.proto | 64 - owl-bot-staging/v1/src/index.ts | 25 - .../v1/document_processor_service_client.ts | 721 -------- ...ument_processor_service_client_config.json | 41 - ...document_processor_service_proto_list.json | 7 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 53 - owl-bot-staging/v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - owl-bot-staging/v1/system-test/install.ts | 49 - .../gapic_document_processor_service_v1.ts | 603 ------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - owl-bot-staging/v1beta1/.eslintignore | 6 - owl-bot-staging/v1beta1/.eslintrc.json | 3 - owl-bot-staging/v1beta1/.gitignore | 14 - owl-bot-staging/v1beta1/.jsdoc.js | 55 - owl-bot-staging/v1beta1/.mocharc.js | 33 - owl-bot-staging/v1beta1/.prettierrc.js | 22 - owl-bot-staging/v1beta1/README.md | 1 - .../v1beta1/linkinator.config.json | 10 - owl-bot-staging/v1beta1/package.json | 64 - .../cloud/documentai/v1beta1/document.proto | 449 ----- .../v1beta1/document_understanding.proto | 302 ---- .../cloud/documentai/v1beta1/geometry.proto | 58 - owl-bot-staging/v1beta1/src/index.ts | 25 - .../document_understanding_service_client.ts | 415 ----- ...t_understanding_service_client_config.json | 31 - ...ment_understanding_service_proto_list.json | 5 - .../v1beta1/src/v1beta1/gapic_metadata.json | 33 - owl-bot-staging/v1beta1/src/v1beta1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta1/system-test/install.ts | 49 - ..._document_understanding_service_v1beta1.ts | 276 --- owl-bot-staging/v1beta1/tsconfig.json | 19 - owl-bot-staging/v1beta1/webpack.config.js | 64 - owl-bot-staging/v1beta2/.eslintignore | 6 - owl-bot-staging/v1beta2/.eslintrc.json | 3 - owl-bot-staging/v1beta2/.gitignore | 14 - owl-bot-staging/v1beta2/.jsdoc.js | 55 - owl-bot-staging/v1beta2/.mocharc.js | 33 - owl-bot-staging/v1beta2/.prettierrc.js | 22 - owl-bot-staging/v1beta2/README.md | 1 - .../v1beta2/linkinator.config.json | 10 - owl-bot-staging/v1beta2/package.json | 64 - .../cloud/documentai/v1beta2/document.proto | 519 ------ .../v1beta2/document_understanding.proto | 346 ---- .../cloud/documentai/v1beta2/geometry.proto | 57 - owl-bot-staging/v1beta2/src/index.ts | 25 - .../document_understanding_service_client.ts | 516 ------ ...t_understanding_service_client_config.json | 36 - ...ment_understanding_service_proto_list.json | 5 - .../v1beta2/src/v1beta2/gapic_metadata.json | 43 - owl-bot-staging/v1beta2/src/v1beta2/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta2/system-test/install.ts | 49 - ..._document_understanding_service_v1beta2.ts | 364 ---- owl-bot-staging/v1beta2/tsconfig.json | 19 - owl-bot-staging/v1beta2/webpack.config.js | 64 - owl-bot-staging/v1beta3/.eslintignore | 6 - owl-bot-staging/v1beta3/.eslintrc.json | 3 - owl-bot-staging/v1beta3/.gitignore | 14 - owl-bot-staging/v1beta3/.jsdoc.js | 55 - owl-bot-staging/v1beta3/.mocharc.js | 33 - owl-bot-staging/v1beta3/.prettierrc.js | 22 - owl-bot-staging/v1beta3/README.md | 1 - .../v1beta3/linkinator.config.json | 10 - owl-bot-staging/v1beta3/package.json | 64 - .../cloud/documentai/v1beta3/document.proto | 730 -------- .../documentai/v1beta3/document_io.proto | 86 - .../v1beta3/document_processor_service.proto | 572 ------ .../cloud/documentai/v1beta3/geometry.proto | 57 - .../v1beta3/operation_metadata.proto | 64 - .../cloud/documentai/v1beta3/processor.proto | 99 - .../documentai/v1beta3/processor_type.proto | 60 - owl-bot-staging/v1beta3/src/index.ts | 25 - .../document_processor_service_client.ts | 1502 ---------------- ...ument_processor_service_client_config.json | 65 - ...document_processor_service_proto_list.json | 9 - .../v1beta3/src/v1beta3/gapic_metadata.json | 117 -- owl-bot-staging/v1beta3/src/v1beta3/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1beta3/system-test/install.ts | 49 - ...apic_document_processor_service_v1beta3.ts | 1587 ----------------- owl-bot-staging/v1beta3/tsconfig.json | 19 - owl-bot-staging/v1beta3/webpack.config.js | 64 - .../v1beta2/document_understanding.proto | 2 +- protos/protos.json | 2 +- src/v1/document_processor_service_client.ts | 2 + .../document_understanding_service_client.ts | 2 + .../document_understanding_service_client.ts | 6 +- .../document_processor_service_client.ts | 2 + 108 files changed, 12 insertions(+), 12842 deletions(-) delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/cloud/documentai/v1/document.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_io.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_processor_service.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/documentai/v1/geometry.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/documentai/v1/operation_metadata.proto delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/document_processor_service_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/document_processor_service_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/document_processor_service_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_document_processor_service_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/v1beta1/.gitignore delete mode 100644 owl-bot-staging/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/v1beta1/README.md delete mode 100644 owl-bot-staging/v1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/v1beta1/package.json delete mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto delete mode 100644 owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto delete mode 100644 owl-bot-staging/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client.ts delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client_config.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_proto_list.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/v1beta1/test/gapic_document_understanding_service_v1beta1.ts delete mode 100644 owl-bot-staging/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/v1beta1/webpack.config.js delete mode 100644 owl-bot-staging/v1beta2/.eslintignore delete mode 100644 owl-bot-staging/v1beta2/.eslintrc.json delete mode 100644 owl-bot-staging/v1beta2/.gitignore delete mode 100644 owl-bot-staging/v1beta2/.jsdoc.js delete mode 100644 owl-bot-staging/v1beta2/.mocharc.js delete mode 100644 owl-bot-staging/v1beta2/.prettierrc.js delete mode 100644 owl-bot-staging/v1beta2/README.md delete mode 100644 owl-bot-staging/v1beta2/linkinator.config.json delete mode 100644 owl-bot-staging/v1beta2/package.json delete mode 100644 owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto delete mode 100644 owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto delete mode 100644 owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto delete mode 100644 owl-bot-staging/v1beta2/src/index.ts delete mode 100644 owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client.ts delete mode 100644 owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client_config.json delete mode 100644 owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_proto_list.json delete mode 100644 owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json delete mode 100644 owl-bot-staging/v1beta2/src/v1beta2/index.ts delete mode 100644 owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1beta2/system-test/install.ts delete mode 100644 owl-bot-staging/v1beta2/test/gapic_document_understanding_service_v1beta2.ts delete mode 100644 owl-bot-staging/v1beta2/tsconfig.json delete mode 100644 owl-bot-staging/v1beta2/webpack.config.js delete mode 100644 owl-bot-staging/v1beta3/.eslintignore delete mode 100644 owl-bot-staging/v1beta3/.eslintrc.json delete mode 100644 owl-bot-staging/v1beta3/.gitignore delete mode 100644 owl-bot-staging/v1beta3/.jsdoc.js delete mode 100644 owl-bot-staging/v1beta3/.mocharc.js delete mode 100644 owl-bot-staging/v1beta3/.prettierrc.js delete mode 100644 owl-bot-staging/v1beta3/README.md delete mode 100644 owl-bot-staging/v1beta3/linkinator.config.json delete mode 100644 owl-bot-staging/v1beta3/package.json delete mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto delete mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto delete mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto delete mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto delete mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto delete mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto delete mode 100644 owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto delete mode 100644 owl-bot-staging/v1beta3/src/index.ts delete mode 100644 owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client.ts delete mode 100644 owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client_config.json delete mode 100644 owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_proto_list.json delete mode 100644 owl-bot-staging/v1beta3/src/v1beta3/gapic_metadata.json delete mode 100644 owl-bot-staging/v1beta3/src/v1beta3/index.ts delete mode 100644 owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1beta3/system-test/install.ts delete mode 100644 owl-bot-staging/v1beta3/test/gapic_document_processor_service_v1beta3.ts delete mode 100644 owl-bot-staging/v1beta3/tsconfig.json delete mode 100644 owl-bot-staging/v1beta3/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index 521dc25a2..000000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b2378..000000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index a00b08ce2..000000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +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. -// -// ** This file 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 2021 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/documentai', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 50bc7f792..000000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 84f4713a0..000000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index f41eef852..000000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Documentai: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index 29a223b6d..000000000 --- a/owl-bot-staging/v1/linkinator.config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io" - ], - "silent": true, - "concurrency": 10 -} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 57616ace7..000000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/documentai", - "version": "0.1.0", - "description": "Documentai client for Node.js", - "repository": "googleapis/nodejs-documentai", - "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 documentai", - "documentai", - "document processor service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.19.0" - }, - "devDependencies": { - "@types/mocha": "^9.0.0", - "@types/node": "^14.17.3", - "@types/sinon": "^10.0.2", - "c8": "^7.7.3", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.0", - "jsdoc-region-tag": "^1.1.0", - "linkinator": "^2.13.6", - "mocha": "^9.0.2", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^11.1.1", - "ts-loader": "^9.2.3", - "typescript": "^4.3.4", - "webpack": "^5.39.1", - "webpack-cli": "^4.7.2" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document.proto b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document.proto deleted file mode 100644 index 467a44921..000000000 --- a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document.proto +++ /dev/null @@ -1,730 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/api/field_behavior.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"; -import "google/api/annotations.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 Understanding -// AI. -// It is an interchange format that provides insights into documents and allows -// for collaboration between users and Document Understanding 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; - } - - // 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; - } - - // 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; - } - - // 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; - } - - // 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; - } - - // 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; - } - - // 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; - - // The history of this annotation. - Provenance provenance = 8; - } - - // Detected language for a structural component. - message DetectedLanguage { - // The BCP-47 language code, such as "en-US" or "sr-Latn". For more - // information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 1; - - // Confidence of detected language. Range [0, 1]. - float confidence = 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; - - // The history of this page. - Provenance provenance = 16; - } - - // A phrase in the text that is a known entity type, such as a person, an - // organization, or location. - message Entity { - // Parsed and normalized entity value. - message NormalizedValue { - // Structured entity value. Must match entity type defined in schema if - // known. If this field is present, the 'text' field is still 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; - } - - // Required. Normalized entity value stored as a string. This field is populated for - // supported document type (e.g. Invoice). For some entity types, one of - // respective 'structured_value' fields may also be populated. - // - // - 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) = REQUIRED]; - } - - // 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]; - - // Entity type from a schema e.g. `Address`. - string type = 2; - - // Optional. Text value in the document 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. - 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 { - // Structure for referencing parent provenances. When an element replaces - // one of more other elements parent references identify the elements that - // are replaced. - message Parent { - // The index of the [Document.revisions] identifying the parent revision. - int32 revision = 1; - - // The index of the parent revisions corresponding collection of items - // (eg. list of entities, properties within entities, etc.) - 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. - OPERATION_TYPE_UNSPECIFIED = 0; - - // Add an element. Implicit if no `parents` are set for the provenance. - ADD = 1; - - // The element is removed. No `parents` should be set. - REMOVE = 2; - - // Explicitly replaces the element(s) identified by `parents`. - REPLACE = 3; - - // Element is requested for human review. - 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; - - // 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; - } - - // 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]; - - // 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; - - // Relationship among [Document.entities][google.cloud.documentai.v1.Document.entities]. - repeated EntityRelation entity_relations = 8; - - // A list of text corrections made to [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; - - // Revision history of this document. - repeated Revision revisions = 13; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_io.proto b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_io.proto deleted file mode 100644 index 1bd020eef..000000000 --- a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_io.proto +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/api/annotations.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]. - 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 Cloud Storage uri (a directory) of the output. - string gcs_uri = 1; - } - - // 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/v1/protos/google/cloud/documentai/v1/document_processor_service.proto b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_processor_service.proto deleted file mode 100644 index 65f0e6d96..000000000 --- a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/document_processor_service.proto +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.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/operation_metadata.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/Location" - pattern: "projects/{project}/locations/{location}" -}; -option (google.api.resource_definition) = { - type: "documentai.googleapis.com/Processor" - pattern: "projects/{project}/locations/{location}/processors/{processor}" -}; -option (google.api.resource_definition) = { - type: "documentai.googleapis.com/HumanReviewConfig" - pattern: "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" -}; - -// 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: "*" - }; - 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: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "BatchProcessResponse" - metadata_type: "BatchProcessMetadata" - }; - } - - // 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 processor resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; - - // Whether Human Review feature should be skipped for this request. Default to - // false. - bool skip_human_review = 3; -} - -// 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 processor resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; - - // 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 of the processing of 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 review document method. -message ReviewDocumentRequest { - reserved 2; - - // 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; -} - -// Response message for review document method. -message ReviewDocumentResponse { - // The Cloud Storage uri for the human reviewed document. - string gcs_destination = 1; -} - -// The long running operation metadata for review document method. -message ReviewDocumentOperationMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} diff --git a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/geometry.proto b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/geometry.proto deleted file mode 100644 index 19ced5073..000000000 --- a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/geometry.proto +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/api/annotations.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 = "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/v1/protos/google/cloud/documentai/v1/operation_metadata.proto b/owl-bot-staging/v1/protos/google/cloud/documentai/v1/operation_metadata.proto deleted file mode 100644 index 503451bf2..000000000 --- a/owl-bot-staging/v1/protos/google/cloud/documentai/v1/operation_metadata.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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"; -import "google/api/annotations.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; - - // 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/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index c72080095..000000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +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. -// -// ** 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 DocumentProcessorServiceClient = v1.DocumentProcessorServiceClient; -type DocumentProcessorServiceClient = v1.DocumentProcessorServiceClient; -export {v1, DocumentProcessorServiceClient}; -export default {v1, DocumentProcessorServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/document_processor_service_client.ts b/owl-bot-staging/v1/src/v1/document_processor_service_client.ts deleted file mode 100644 index 2c9803641..000000000 --- a/owl-bot-staging/v1/src/v1/document_processor_service_client.ts +++ /dev/null @@ -1,721 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/document_processor_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './document_processor_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * 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. - * @class - * @memberof v1 - */ -export class DocumentProcessorServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - documentProcessorServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DocumentProcessorServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DocumentProcessorServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - humanReviewConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig' - ), - processorPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/processors/{processor}' - ), - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const batchProcessDocumentsResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.BatchProcessResponse') as gax.protobuf.Type; - const batchProcessDocumentsMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.BatchProcessMetadata') as gax.protobuf.Type; - const reviewDocumentResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.ReviewDocumentResponse') as gax.protobuf.Type; - const reviewDocumentMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.ReviewDocumentOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - batchProcessDocumentsResponse.decode.bind(batchProcessDocumentsResponse), - batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata)), - reviewDocument: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - reviewDocumentResponse.decode.bind(reviewDocumentResponse), - reviewDocumentMetadata.decode.bind(reviewDocumentMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.documentai.v1.DocumentProcessorService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.documentProcessorServiceStub) { - return this.documentProcessorServiceStub; - } - - // Put together the "service stub" for - // google.cloud.documentai.v1.DocumentProcessorService. - this.documentProcessorServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.documentai.v1.DocumentProcessorService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.documentai.v1.DocumentProcessorService, - 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 documentProcessorServiceStubMethods = - ['processDocument', 'batchProcessDocuments', 'reviewDocument']; - for (const methodName of documentProcessorServiceStubMethods) { - const callPromise = this.documentProcessorServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.documentProcessorServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'documentai.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 'documentai.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 -- - // ------------------- - processDocument( - request?: protos.google.cloud.documentai.v1.IProcessRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1.IProcessResponse, - protos.google.cloud.documentai.v1.IProcessRequest|undefined, {}|undefined - ]>; - processDocument( - request: protos.google.cloud.documentai.v1.IProcessRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1.IProcessResponse, - protos.google.cloud.documentai.v1.IProcessRequest|null|undefined, - {}|null|undefined>): void; - processDocument( - request: protos.google.cloud.documentai.v1.IProcessRequest, - callback: Callback< - protos.google.cloud.documentai.v1.IProcessResponse, - protos.google.cloud.documentai.v1.IProcessRequest|null|undefined, - {}|null|undefined>): void; -/** - * Processes a single document. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.documentai.v1.Document} request.inlineDocument - * An inline document proto. - * @param {google.cloud.documentai.v1.RawDocument} request.rawDocument - * A raw document content (bytes). - * @param {string} request.name - * Required. The processor resource name. - * @param {boolean} request.skipHumanReview - * Whether Human Review feature should be skipped for this request. Default to - * false. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProcessResponse]{@link google.cloud.documentai.v1.ProcessResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.processDocument(request); - */ - processDocument( - request?: protos.google.cloud.documentai.v1.IProcessRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1.IProcessResponse, - protos.google.cloud.documentai.v1.IProcessRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1.IProcessResponse, - protos.google.cloud.documentai.v1.IProcessRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1.IProcessResponse, - protos.google.cloud.documentai.v1.IProcessRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.processDocument(request, options, callback); - } - - batchProcessDocuments( - request?: protos.google.cloud.documentai.v1.IBatchProcessRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - batchProcessDocuments( - request: protos.google.cloud.documentai.v1.IBatchProcessRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - batchProcessDocuments( - request: protos.google.cloud.documentai.v1.IBatchProcessRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * LRO endpoint to batch process many documents. The output is written - * to Cloud Storage as JSON in the [Document] format. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor resource name. - * @param {google.cloud.documentai.v1.BatchDocumentsInputConfig} request.inputDocuments - * The input documents for batch process. - * @param {google.cloud.documentai.v1.DocumentOutputConfig} request.documentOutputConfig - * The overall output config for batch process. - * @param {boolean} request.skipHumanReview - * Whether Human Review feature should be skipped for this request. Default to - * false. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.batchProcessDocuments(request); - * const [response] = await operation.promise(); - */ - batchProcessDocuments( - request?: protos.google.cloud.documentai.v1.IBatchProcessRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.batchProcessDocuments(request, options, callback); - } -/** - * Check the status of the long running operation returned by `batchProcessDocuments()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkBatchProcessDocumentsProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkBatchProcessDocumentsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - reviewDocument( - request?: protos.google.cloud.documentai.v1.IReviewDocumentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - reviewDocument( - request: protos.google.cloud.documentai.v1.IReviewDocumentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - reviewDocument( - request: protos.google.cloud.documentai.v1.IReviewDocumentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Send a document for Human Review. The input document should be processed by - * the specified processor. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.documentai.v1.Document} request.inlineDocument - * An inline document proto. - * @param {string} request.humanReviewConfig - * Required. The resource name of the HumanReviewConfig that the document will be - * reviewed with. - * @param {boolean} request.enableSchemaValidation - * Whether the validation should be performed on the ad-hoc review request. - * @param {google.cloud.documentai.v1.ReviewDocumentRequest.Priority} request.priority - * The priority of the human review task. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.reviewDocument(request); - * const [response] = await operation.promise(); - */ - reviewDocument( - request?: protos.google.cloud.documentai.v1.IReviewDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'human_review_config': request.humanReviewConfig || '', - }); - this.initialize(); - return this.innerApiCalls.reviewDocument(request, options, callback); - } -/** - * Check the status of the long running operation returned by `reviewDocument()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkReviewDocumentProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkReviewDocumentProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.reviewDocument, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified humanReviewConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} processor - * @returns {string} Resource name string. - */ - humanReviewConfigPath(project:string,location:string,processor:string) { - return this.pathTemplates.humanReviewConfigPathTemplate.render({ - project: project, - location: location, - processor: processor, - }); - } - - /** - * Parse the project from HumanReviewConfig resource. - * - * @param {string} humanReviewConfigName - * A fully-qualified path representing HumanReviewConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromHumanReviewConfigName(humanReviewConfigName: string) { - return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).project; - } - - /** - * Parse the location from HumanReviewConfig resource. - * - * @param {string} humanReviewConfigName - * A fully-qualified path representing HumanReviewConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromHumanReviewConfigName(humanReviewConfigName: string) { - return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).location; - } - - /** - * Parse the processor from HumanReviewConfig resource. - * - * @param {string} humanReviewConfigName - * A fully-qualified path representing HumanReviewConfig resource. - * @returns {string} A string representing the processor. - */ - matchProcessorFromHumanReviewConfigName(humanReviewConfigName: string) { - return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).processor; - } - - /** - * Return a fully-qualified processor resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} processor - * @returns {string} Resource name string. - */ - processorPath(project:string,location:string,processor:string) { - return this.pathTemplates.processorPathTemplate.render({ - project: project, - location: location, - processor: processor, - }); - } - - /** - * Parse the project from Processor resource. - * - * @param {string} processorName - * A fully-qualified path representing Processor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProcessorName(processorName: string) { - return this.pathTemplates.processorPathTemplate.match(processorName).project; - } - - /** - * Parse the location from Processor resource. - * - * @param {string} processorName - * A fully-qualified path representing Processor resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProcessorName(processorName: string) { - return this.pathTemplates.processorPathTemplate.match(processorName).location; - } - - /** - * Parse the processor from Processor resource. - * - * @param {string} processorName - * A fully-qualified path representing Processor resource. - * @returns {string} A string representing the processor. - */ - matchProcessorFromProcessorName(processorName: string) { - return this.pathTemplates.processorPathTemplate.match(processorName).processor; - } - - /** - * 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 { - this.initialize(); - if (!this._terminated) { - return this.documentProcessorServiceStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/document_processor_service_client_config.json b/owl-bot-staging/v1/src/v1/document_processor_service_client_config.json deleted file mode 100644 index 0ded43290..000000000 --- a/owl-bot-staging/v1/src/v1/document_processor_service_client_config.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "interfaces": { - "google.cloud.documentai.v1.DocumentProcessorService": { - "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": { - "ProcessDocument": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "BatchProcessDocuments": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ReviewDocument": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/document_processor_service_proto_list.json b/owl-bot-staging/v1/src/v1/document_processor_service_proto_list.json deleted file mode 100644 index 49fea13a7..000000000 --- a/owl-bot-staging/v1/src/v1/document_processor_service_proto_list.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - "../../protos/google/cloud/documentai/v1/document.proto", - "../../protos/google/cloud/documentai/v1/document_io.proto", - "../../protos/google/cloud/documentai/v1/document_processor_service.proto", - "../../protos/google/cloud/documentai/v1/geometry.proto", - "../../protos/google/cloud/documentai/v1/operation_metadata.proto" -] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 05ebff671..000000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.documentai.v1", - "libraryPackage": "@google-cloud/documentai", - "services": { - "DocumentProcessorService": { - "clients": { - "grpc": { - "libraryClient": "DocumentProcessorServiceClient", - "rpcs": { - "ProcessDocument": { - "methods": [ - "processDocument" - ] - }, - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - }, - "ReviewDocument": { - "methods": [ - "reviewDocument" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentProcessorServiceClient", - "rpcs": { - "ProcessDocument": { - "methods": [ - "processDocument" - ] - }, - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - }, - "ReviewDocument": { - "methods": [ - "reviewDocument" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 2f6c91a42..000000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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. -// -// ** 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 {DocumentProcessorServiceClient} from './document_processor_service_client'; diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 7a0b0174d..000000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +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. -// -// ** 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 documentai = require('@google-cloud/documentai'); - -function main() { - const documentProcessorServiceClient = new documentai.DocumentProcessorServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 2bccab99e..000000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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. -// -// ** 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 {DocumentProcessorServiceClient} from '@google-cloud/documentai'; - -// check that the client class type name can be used -function doStuffWithDocumentProcessorServiceClient(client: DocumentProcessorServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const documentProcessorServiceClient = new DocumentProcessorServiceClient(); - doStuffWithDocumentProcessorServiceClient(documentProcessorServiceClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 1f850b522..000000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1/test/gapic_document_processor_service_v1.ts b/owl-bot-staging/v1/test/gapic_document_processor_service_v1.ts deleted file mode 100644 index 801a74e6d..000000000 --- a/owl-bot-staging/v1/test/gapic_document_processor_service_v1.ts +++ /dev/null @@ -1,603 +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. -// -// ** 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 documentprocessorserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1.DocumentProcessorServiceClient', () => { - it('has servicePath', () => { - const servicePath = documentprocessorserviceModule.v1.DocumentProcessorServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = documentprocessorserviceModule.v1.DocumentProcessorServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = documentprocessorserviceModule.v1.DocumentProcessorServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentProcessorServiceStub, undefined); - await client.initialize(); - assert(client.documentProcessorServiceStub); - }); - - it('has close method', () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - 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 documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - 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('processDocument', () => { - it('invokes processDocument without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessResponse()); - client.innerApiCalls.processDocument = stubSimpleCall(expectedResponse); - const [response] = await client.processDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.processDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes processDocument without error using callback', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessResponse()); - client.innerApiCalls.processDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.processDocument( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.processDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes processDocument with error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.processDocument(request), expectedError); - assert((client.innerApiCalls.processDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('batchProcessDocuments', () => { - it('invokes batchProcessDocuments without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.BatchProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchProcessDocuments(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchProcessDocuments without error using callback', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.BatchProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchProcessDocuments( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchProcessDocuments with call error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.BatchProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchProcessDocuments(request), expectedError); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchProcessDocuments with LRO error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.BatchProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchProcessDocuments(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkBatchProcessDocumentsProgress without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchProcessDocumentsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkBatchProcessDocumentsProgress with error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchProcessDocumentsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('reviewDocument', () => { - it('invokes reviewDocument without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ReviewDocumentRequest()); - request.humanReviewConfig = ''; - const expectedHeaderRequestParams = "human_review_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.reviewDocument = stubLongRunningCall(expectedResponse); - const [operation] = await client.reviewDocument(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes reviewDocument without error using callback', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ReviewDocumentRequest()); - request.humanReviewConfig = ''; - const expectedHeaderRequestParams = "human_review_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.reviewDocument = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reviewDocument( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes reviewDocument with call error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ReviewDocumentRequest()); - request.humanReviewConfig = ''; - const expectedHeaderRequestParams = "human_review_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reviewDocument(request), expectedError); - assert((client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes reviewDocument with LRO error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1.ReviewDocumentRequest()); - request.humanReviewConfig = ''; - const expectedHeaderRequestParams = "human_review_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reviewDocument(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkReviewDocumentProgress without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkReviewDocumentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkReviewDocumentProgress with error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReviewDocumentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('Path templates', () => { - - describe('humanReviewConfig', () => { - const fakePath = "/rendered/path/humanReviewConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - processor: "processorValue", - }; - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.humanReviewConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.humanReviewConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('humanReviewConfigPath', () => { - const result = client.humanReviewConfigPath("projectValue", "locationValue", "processorValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.humanReviewConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHumanReviewConfigName', () => { - const result = client.matchProjectFromHumanReviewConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromHumanReviewConfigName', () => { - const result = client.matchLocationFromHumanReviewConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorFromHumanReviewConfigName', () => { - const result = client.matchProcessorFromHumanReviewConfigName(fakePath); - assert.strictEqual(result, "processorValue"); - assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('processor', () => { - const fakePath = "/rendered/path/processor"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - processor: "processorValue", - }; - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.processorPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.processorPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('processorPath', () => { - const result = client.processorPath("projectValue", "locationValue", "processorValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.processorPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProcessorName', () => { - const result = client.matchProjectFromProcessorName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.processorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProcessorName', () => { - const result = client.matchLocationFromProcessorName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.processorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorFromProcessorName', () => { - const result = client.matchProcessorFromProcessorName(fakePath); - assert.strictEqual(result, "processorValue"); - assert((client.pathTemplates.processorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index fc7bef574..000000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'DocumentProcessorService', - filename: './document-processor-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/owl-bot-staging/v1beta1/.eslintignore b/owl-bot-staging/v1beta1/.eslintignore deleted file mode 100644 index 521dc25a2..000000000 --- a/owl-bot-staging/v1beta1/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ diff --git a/owl-bot-staging/v1beta1/.eslintrc.json b/owl-bot-staging/v1beta1/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1beta1/.gitignore b/owl-bot-staging/v1beta1/.gitignore deleted file mode 100644 index 5d32b2378..000000000 --- a/owl-bot-staging/v1beta1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1beta1/.jsdoc.js b/owl-bot-staging/v1beta1/.jsdoc.js deleted file mode 100644 index b9a6b9977..000000000 --- a/owl-bot-staging/v1beta1/.jsdoc.js +++ /dev/null @@ -1,55 +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. -// -// ** This file 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 2021 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: 'documentai', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1beta1/.mocharc.js b/owl-bot-staging/v1beta1/.mocharc.js deleted file mode 100644 index 50bc7f792..000000000 --- a/owl-bot-staging/v1beta1/.mocharc.js +++ /dev/null @@ -1,33 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1beta1/.prettierrc.js b/owl-bot-staging/v1beta1/.prettierrc.js deleted file mode 100644 index 84f4713a0..000000000 --- a/owl-bot-staging/v1beta1/.prettierrc.js +++ /dev/null @@ -1,22 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1beta1/README.md b/owl-bot-staging/v1beta1/README.md deleted file mode 100644 index f41eef852..000000000 --- a/owl-bot-staging/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Documentai: Nodejs Client diff --git a/owl-bot-staging/v1beta1/linkinator.config.json b/owl-bot-staging/v1beta1/linkinator.config.json deleted file mode 100644 index 29a223b6d..000000000 --- a/owl-bot-staging/v1beta1/linkinator.config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io" - ], - "silent": true, - "concurrency": 10 -} diff --git a/owl-bot-staging/v1beta1/package.json b/owl-bot-staging/v1beta1/package.json deleted file mode 100644 index b990b7473..000000000 --- a/owl-bot-staging/v1beta1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "documentai", - "version": "0.1.0", - "description": "Documentai client for Node.js", - "repository": "googleapis/nodejs-documentai", - "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 documentai", - "documentai", - "document understanding service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.19.0" - }, - "devDependencies": { - "@types/mocha": "^9.0.0", - "@types/node": "^14.17.3", - "@types/sinon": "^10.0.2", - "c8": "^7.7.3", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.0", - "jsdoc-region-tag": "^1.1.0", - "linkinator": "^2.13.6", - "mocha": "^9.0.2", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^11.1.1", - "ts-loader": "^9.2.3", - "typescript": "^4.3.4", - "webpack": "^5.39.1", - "webpack-cli": "^4.7.2" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto b/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto deleted file mode 100644 index 2c47f6f22..000000000 --- a/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto +++ /dev/null @@ -1,449 +0,0 @@ -// Copyright 2019 Google LLC. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.cloud.documentai.v1beta1; - -import "google/api/annotations.proto"; -import "google/cloud/documentai/v1beta1/geometry.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentProto"; -option java_package = "com.google.cloud.documentai.v1beta1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta1"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta1"; - -// Document represents the canonical document resource in Document Understanding -// AI. -// It is an interchange format that provides insights into documents and allows -// for collaboration between users and Document Understanding 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.v1beta1.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.v1beta1.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; - } - - // A page in a [Document][google.cloud.documentai.v1beta1.Document]. - message Page { - // Dimension for the page. - message Dimension { - // Page width. - float width = 1; - - // Page height. - float height = 2; - - // Dimension unit. - string unit = 3; - } - - // 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.v1beta1.Document.text]. - TextAnchor text_anchor = 1; - - // Confidence of the current - // [Layout][google.cloud.documentai.v1beta1.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.v1beta1.Document.Page.Layout]. - BoundingPoly bounding_poly = 3; - - // Detected orientation for the - // [Layout][google.cloud.documentai.v1beta1.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.v1beta1.Document.Page.Layout] for - // [Block][google.cloud.documentai.v1beta1.Document.Page.Block]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - } - - // A collection of lines that a human would perceive as a paragraph. - message Paragraph { - // [Layout][google.cloud.documentai.v1beta1.Document.Page.Layout] for - // [Paragraph][google.cloud.documentai.v1beta1.Document.Page.Paragraph]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - } - - // 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.v1beta1.Document.Page.Layout] for - // [Line][google.cloud.documentai.v1beta1.Document.Page.Line]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - } - - // A detected token. - message Token { - // Detected break at the end of a - // [Token][google.cloud.documentai.v1beta1.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.v1beta1.Document.Page.Layout] for - // [Token][google.cloud.documentai.v1beta1.Document.Page.Token]. - Layout layout = 1; - - // Detected break at the end of a - // [Token][google.cloud.documentai.v1beta1.Document.Page.Token]. - DetectedBreak detected_break = 2; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 3; - } - - // Detected non-text visual elements e.g. checkbox, signature etc. on the - // page. - message VisualElement { - // [Layout][google.cloud.documentai.v1beta1.Document.Page.Layout] for - // [Token][google.cloud.documentai.v1beta1.Document.Page.Token]. - Layout layout = 1; - - // Type of the - // [VisualElement][google.cloud.documentai.v1beta1.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.v1beta1.Document.Page.Layout] for - // [TableCell][google.cloud.documentai.v1beta1.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.v1beta1.Document.Page.Layout] for - // [Table][google.cloud.documentai.v1beta1.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; - } - - // A form field detected on the page. - message FormField { - // [Layout][google.cloud.documentai.v1beta1.Document.Page.Layout] for the - // [FormField][google.cloud.documentai.v1beta1.Document.Page.FormField] - // name. e.g. `Address`, `Email`, `Grand total`, `Phone number`, etc. - Layout field_name = 1; - - // [Layout][google.cloud.documentai.v1beta1.Document.Page.Layout] for the - // [FormField][google.cloud.documentai.v1beta1.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; - } - - // Detected language for a structural component. - message DetectedLanguage { - // The BCP-47 language code, such as "en-US" or "sr-Latn". For more - // information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 1; - - // Confidence of detected language. Range [0, 1]. - float confidence = 2; - } - - // 1-based index for current - // [Page][google.cloud.documentai.v1beta1.Document.Page] in a parent - // [Document][google.cloud.documentai.v1beta1.Document]. Useful when a page - // is taken out of a [Document][google.cloud.documentai.v1beta1.Document] - // for individual processing. - int32 page_number = 1; - - // Physical dimension of the page. - Dimension dimension = 2; - - // [Layout][google.cloud.documentai.v1beta1.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 phrase in the text that is a known entity type, such as a person, an - // organization, or location. - message Entity { - // Provenance of the entity. - // Text anchor indexing into the - // [Document.text][google.cloud.documentai.v1beta1.Document.text]. - TextAnchor text_anchor = 1; - - // Entity type from a schema e.g. `Address`. - string type = 2; - - // Text value in the document e.g. `1600 Amphitheatre Pkwy`. - string mention_text = 3; - - // Canonical mention name. This will be a unique value in the entity list - // for this document. - string mention_id = 4; - } - - // Relationship between - // [Entities][google.cloud.documentai.v1beta1.Document.Entity]. - message EntityRelation { - // Subject entity mention_id. - string subject_id = 1; - - // Object entity mention_id. - string object_id = 2; - - // Relationship description. - string relation = 3; - } - - // Text reference indexing into the - // [Document.text][google.cloud.documentai.v1beta1.Document.text]. - message TextAnchor { - // A text segment in the - // [Document.text][google.cloud.documentai.v1beta1.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.v1beta1.Document.ShardInfo.text_offset] - message TextSegment { - // [TextSegment][google.cloud.documentai.v1beta1.Document.TextAnchor.TextSegment] - // start UTF-8 char index in the - // [Document.text][google.cloud.documentai.v1beta1.Document.text]. - int64 start_index = 1; - - // [TextSegment][google.cloud.documentai.v1beta1.Document.TextAnchor.TextSegment] - // half open end UTF-8 char index in the - // [Document.text][google.cloud.documentai.v1beta1.Document.text]. - int64 end_index = 2; - } - - // The text segments from the - // [Document.text][google.cloud.documentai.v1beta1.Document.text]. - repeated TextSegment text_segments = 1; - } - - // Original source document from the user. - oneof source { - // 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; - - // 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; - } - - // 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; - - // UTF-8 encoded text in reading order from the document. - string text = 4; - - // Styles for the - // [Document.text][google.cloud.documentai.v1beta1.Document.text]. - repeated Style text_styles = 5; - - // Visual page layout for the - // [Document][google.cloud.documentai.v1beta1.Document]. - repeated Page pages = 6; - - // A list of entities detected on - // [Document.text][google.cloud.documentai.v1beta1.Document.text]. For - // document shards, entities in this list may cross shard boundaries. - repeated Entity entities = 7; - - // Relationship among - // [Document.entities][google.cloud.documentai.v1beta1.Document.entities]. - repeated EntityRelation entity_relations = 8; - - // 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; -} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto b/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto deleted file mode 100644 index eb17286d4..000000000 --- a/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright 2019 Google LLC. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.cloud.documentai.v1beta1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/documentai/v1beta1/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProto"; -option java_package = "com.google.cloud.documentai.v1beta1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta1"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta1"; - -// Service to parse structured information from unstructured or semi-structured -// documents using state-of-the-art Google AI such as natural language, -// computer vision, and translation. -service DocumentUnderstandingService { - option (google.api.default_host) = "documentai.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // LRO endpoint to batch process many documents. - rpc BatchProcessDocuments(BatchProcessDocumentsRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta1/{parent=projects/*/locations/*}/documents:batchProcess" - body: "*" - additional_bindings { - post: "/v1beta1/{parent=projects/*}/documents:batchProcess" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "BatchProcessDocumentsResponse" - metadata_type: "OperationMetadata" - }; - } -} - -// Request to batch process documents as an asynchronous operation. -message BatchProcessDocumentsRequest { - // Required. Individual requests for each document. - repeated ProcessDocumentRequest requests = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no location is specified, a region will be chosen automatically. - string parent = 2; -} - -// Request to process one document. -message ProcessDocumentRequest { - // Required. Information about the input file. - InputConfig input_config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The desired output location. - OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED]; - - // Specifies a known document type for deeper structure detection. Valid - // values are currently "general" and "invoice". If not provided, "general"\ - // is used as default. If any other value is given, the request is rejected. - string document_type = 3; - - // Controls table extraction behavior. If not specified, the system will - // decide reasonable defaults. - TableExtractionParams table_extraction_params = 4; - - // Controls form extraction behavior. If not specified, the system will - // decide reasonable defaults. - FormExtractionParams form_extraction_params = 5; - - // Controls entity extraction behavior. If not specified, the system will - // decide reasonable defaults. - EntityExtractionParams entity_extraction_params = 6; - - // Controls OCR behavior. If not specified, the system will decide reasonable - // defaults. - OcrParams ocr_params = 7; -} - -// Response to an batch document processing request. This is returned in -// the LRO Operation after the operation is complete. -message BatchProcessDocumentsResponse { - // Responses for each individual document. - repeated ProcessDocumentResponse responses = 1; -} - -// Response to a single document processing request. -message ProcessDocumentResponse { - // Information about the input file. This is the same as the corresponding - // input config in the request. - InputConfig input_config = 1; - - // The output location of the parsed responses. The responses are written to - // this location as JSON-serialized `Document` objects. - OutputConfig output_config = 2; -} - -// Parameters to control Optical Character Recognition (OCR) behavior. -message OcrParams { - // List of languages to use for OCR. In most cases, an empty value - // yields the best results since it enables automatic language detection. For - // languages based on the Latin alphabet, setting `language_hints` is not - // needed. In rare cases, when the language of the text in the image is known, - // setting a hint will help get better results (although it will be a - // significant hindrance if the hint is wrong). Document processing returns an - // error if one or more of the specified languages is not one of the - // supported languages. - repeated string language_hints = 1; -} - -// Parameters to control table extraction behavior. -message TableExtractionParams { - // Whether to enable table extraction. - bool enabled = 1; - - // Optional. Table bounding box hints that can be provided to complex cases - // which our algorithm cannot locate the table(s) in. - repeated TableBoundHint table_bound_hints = 2 - [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Table header hints. The extraction will bias towards producing - // these terms as table headers, which may improve accuracy. - repeated string header_hints = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Model version of the table extraction system. Default is "builtin/stable". - // Specify "builtin/latest" for the latest model. - string model_version = 4; -} - -// A hint for a table bounding box on the page for table parsing. -message TableBoundHint { - // Optional. Page number for multi-paged inputs this hint applies to. If not - // provided, this hint will apply to all pages by default. This value is - // 1-based. - int32 page_number = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Bounding box hint for a table on this page. The coordinates must be - // normalized to [0,1] and the bounding box must be an axis-aligned rectangle. - BoundingPoly bounding_box = 2; -} - -// Parameters to control form extraction behavior. -message FormExtractionParams { - // Whether to enable form extraction. - bool enabled = 1; - - // User can provide pairs of (key text, value type) to improve the parsing - // result. - // - // For example, if a document has a field called "Date" that holds a date - // value and a field called "Amount" that may hold either a currency value - // (e.g., "$500.00") or a simple number value (e.g., "20"), you could use the - // following hints: [ {"key": "Date", value_types: [ "DATE"]}, {"key": - // "Amount", "value_types": [ "PRICE", "NUMBER" ]} ] - // - // If the value type is unknown, but you want to provide hints for the keys, - // you can leave the value_types field blank. e.g. {"key": "Date", - // "value_types": []} - repeated KeyValuePairHint key_value_pair_hints = 2; - - // Model version of the form extraction system. Default is - // "builtin/stable". Specify "builtin/latest" for the latest model. - string model_version = 3; -} - -// User-provided hint for key value pair. -message KeyValuePairHint { - // The key text for the hint. - string key = 1; - - // Type of the value. This is case-insensitive, and could be one of: - // ADDRESS, LOCATION, ORGANIZATION, PERSON, PHONE_NUMBER, - // ID, NUMBER, EMAIL, PRICE, TERMS, DATE, NAME. Types not in this list will - // be ignored. - repeated string value_types = 2; -} - -// Parameters to control entity extraction behavior. -message EntityExtractionParams { - // Whether to enable entity extraction. - bool enabled = 1; - - // Model version of the entity extraction. Default is - // "builtin/stable". Specify "builtin/latest" for the latest model. - string model_version = 2; -} - -// The desired input location and metadata. -message InputConfig { - // Required. - oneof source { - // The Google Cloud Storage location to read the input from. This must be a - // single file. - GcsSource gcs_source = 1; - } - - // Required. Mimetype of the input. Current supported mimetypes are - // application/pdf, image/tiff, and image/gif. - string mime_type = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The desired output location and metadata. -message OutputConfig { - // Required. - oneof destination { - // The Google Cloud Storage location to write the output to. - GcsDestination gcs_destination = 1; - } - - // The max number of pages to include into each output Document shard JSON on - // Google Cloud Storage. - // - // The valid range is [1, 100]. If not specified, the default value is 20. - // - // For example, for one pdf file with 100 pages, 100 parsed pages will be - // produced. If `pages_per_shard` = 20, then 5 Document shard JSON files each - // containing 20 parsed pages will be written under the prefix - // [OutputConfig.gcs_destination.uri][] and suffix pages-x-to-y.json where - // x and y are 1-indexed page numbers. - // - // Example GCS outputs with 157 pages and pages_per_shard = 50: - // - // pages-001-to-050.json - // pages-051-to-100.json - // pages-101-to-150.json - // pages-151-to-157.json - int32 pages_per_shard = 2; -} - -// The Google Cloud Storage location where the input file will be read from. -message GcsSource { - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The Google Cloud Storage location where the output file will be written to. -message GcsDestination { - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Contains metadata for the BatchProcessDocuments operation. -message OperationMetadata { - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // Request is received. - ACCEPTED = 1; - - // Request operation is waiting for scheduling. - WAITING = 2; - - // Request is being processed. - RUNNING = 3; - - // The batch processing completed successfully. - SUCCEEDED = 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. - 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; -} diff --git a/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto b/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto deleted file mode 100644 index 631c179c3..000000000 --- a/owl-bot-staging/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2019 Google LLC. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.cloud.documentai.v1beta1; - -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.documentai.v1beta1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta1"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta1"; - -// 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. - 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. - 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/v1beta1/src/index.ts b/owl-bot-staging/v1beta1/src/index.ts deleted file mode 100644 index 2e481c053..000000000 --- a/owl-bot-staging/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1beta1 from './v1beta1'; -const DocumentUnderstandingServiceClient = v1beta1.DocumentUnderstandingServiceClient; -type DocumentUnderstandingServiceClient = v1beta1.DocumentUnderstandingServiceClient; -export {v1beta1, DocumentUnderstandingServiceClient}; -export default {v1beta1, DocumentUnderstandingServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client.ts b/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client.ts deleted file mode 100644 index a0e9f0bf5..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client.ts +++ /dev/null @@ -1,415 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta1/document_understanding_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './document_understanding_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service to parse structured information from unstructured or semi-structured - * documents using state-of-the-art Google AI such as natural language, - * computer vision, and translation. - * @class - * @memberof v1beta1 - */ -export class DocumentUnderstandingServiceClient { - 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}; - operationsClient: gax.OperationsClient; - documentUnderstandingServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DocumentUnderstandingServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DocumentUnderstandingServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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); - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const batchProcessDocumentsResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta1.BatchProcessDocumentsResponse') as gax.protobuf.Type; - const batchProcessDocumentsMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta1.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - batchProcessDocumentsResponse.decode.bind(batchProcessDocumentsResponse), - batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.documentai.v1beta1.DocumentUnderstandingService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.documentUnderstandingServiceStub) { - return this.documentUnderstandingServiceStub; - } - - // Put together the "service stub" for - // google.cloud.documentai.v1beta1.DocumentUnderstandingService. - this.documentUnderstandingServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.documentai.v1beta1.DocumentUnderstandingService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.documentai.v1beta1.DocumentUnderstandingService, - 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 documentUnderstandingServiceStubMethods = - ['batchProcessDocuments']; - for (const methodName of documentUnderstandingServiceStubMethods) { - const callPromise = this.documentUnderstandingServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.documentUnderstandingServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'documentai.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 'documentai.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 -- - // ------------------- - - batchProcessDocuments( - request?: protos.google.cloud.documentai.v1beta1.IBatchProcessDocumentsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - batchProcessDocuments( - request: protos.google.cloud.documentai.v1beta1.IBatchProcessDocumentsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - batchProcessDocuments( - request: protos.google.cloud.documentai.v1beta1.IBatchProcessDocumentsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * LRO endpoint to batch process many documents. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual requests for each document. - * @param {string} request.parent - * Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no location is specified, a region will be chosen automatically. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.batchProcessDocuments(request); - * const [response] = await operation.promise(); - */ - batchProcessDocuments( - request?: protos.google.cloud.documentai.v1beta1.IBatchProcessDocumentsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.batchProcessDocuments(request, options, callback); - } -/** - * Check the status of the long running operation returned by `batchProcessDocuments()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkBatchProcessDocumentsProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkBatchProcessDocumentsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - - /** - * 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 { - this.initialize(); - if (!this._terminated) { - return this.documentUnderstandingServiceStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client_config.json b/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client_config.json deleted file mode 100644 index 2b4b0aff7..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_client_config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "interfaces": { - "google.cloud.documentai.v1beta1.DocumentUnderstandingService": { - "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": { - "BatchProcessDocuments": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_proto_list.json b/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_proto_list.json deleted file mode 100644 index 684a577c0..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/document_understanding_service_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/documentai/v1beta1/document.proto", - "../../protos/google/cloud/documentai/v1beta1/document_understanding.proto", - "../../protos/google/cloud/documentai/v1beta1/geometry.proto" -] diff --git a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index ec68421d5..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/gapic_metadata.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.documentai.v1beta1", - "libraryPackage": "documentai", - "services": { - "DocumentUnderstandingService": { - "clients": { - "grpc": { - "libraryClient": "DocumentUnderstandingServiceClient", - "rpcs": { - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentUnderstandingServiceClient", - "rpcs": { - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index 1a00861f8..000000000 --- a/owl-bot-staging/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +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. -// -// ** 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 {DocumentUnderstandingServiceClient} from './document_understanding_service_client'; diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 7835b7bc5..000000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +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. -// -// ** 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 documentai = require('documentai'); - -function main() { - const documentUnderstandingServiceClient = new documentai.DocumentUnderstandingServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index d399cead7..000000000 --- a/owl-bot-staging/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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. -// -// ** 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 {DocumentUnderstandingServiceClient} from 'documentai'; - -// check that the client class type name can be used -function doStuffWithDocumentUnderstandingServiceClient(client: DocumentUnderstandingServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const documentUnderstandingServiceClient = new DocumentUnderstandingServiceClient(); - doStuffWithDocumentUnderstandingServiceClient(documentUnderstandingServiceClient); -} - -main(); diff --git a/owl-bot-staging/v1beta1/system-test/install.ts b/owl-bot-staging/v1beta1/system-test/install.ts deleted file mode 100644 index 1f850b522..000000000 --- a/owl-bot-staging/v1beta1/system-test/install.ts +++ /dev/null @@ -1,49 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1beta1/test/gapic_document_understanding_service_v1beta1.ts b/owl-bot-staging/v1beta1/test/gapic_document_understanding_service_v1beta1.ts deleted file mode 100644 index 8fd3a94c0..000000000 --- a/owl-bot-staging/v1beta1/test/gapic_document_understanding_service_v1beta1.ts +++ /dev/null @@ -1,276 +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. -// -// ** 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 documentunderstandingserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1beta1.DocumentUnderstandingServiceClient', () => { - it('has servicePath', () => { - const servicePath = documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentUnderstandingServiceStub, undefined); - await client.initialize(); - assert(client.documentUnderstandingServiceStub); - }); - - it('has close method', () => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - 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 documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - 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('batchProcessDocuments', () => { - it('invokes batchProcessDocuments without error', async () => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchProcessDocuments(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchProcessDocuments without error using callback', async () => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchProcessDocuments( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchProcessDocuments with call error', async () => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchProcessDocuments(request), expectedError); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchProcessDocuments with LRO error', async () => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchProcessDocuments(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkBatchProcessDocumentsProgress without error', async () => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchProcessDocumentsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkBatchProcessDocumentsProgress with error', async () => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchProcessDocumentsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); -}); diff --git a/owl-bot-staging/v1beta1/tsconfig.json b/owl-bot-staging/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/v1beta1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1beta1/webpack.config.js b/owl-bot-staging/v1beta1/webpack.config.js deleted file mode 100644 index c6fdde565..000000000 --- a/owl-bot-staging/v1beta1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'DocumentUnderstandingService', - filename: './document-understanding-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/owl-bot-staging/v1beta2/.eslintignore b/owl-bot-staging/v1beta2/.eslintignore deleted file mode 100644 index 521dc25a2..000000000 --- a/owl-bot-staging/v1beta2/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ diff --git a/owl-bot-staging/v1beta2/.eslintrc.json b/owl-bot-staging/v1beta2/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/v1beta2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1beta2/.gitignore b/owl-bot-staging/v1beta2/.gitignore deleted file mode 100644 index 5d32b2378..000000000 --- a/owl-bot-staging/v1beta2/.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/v1beta2/.jsdoc.js b/owl-bot-staging/v1beta2/.jsdoc.js deleted file mode 100644 index a00b08ce2..000000000 --- a/owl-bot-staging/v1beta2/.jsdoc.js +++ /dev/null @@ -1,55 +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. -// -// ** This file 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 2021 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/documentai', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1beta2/.mocharc.js b/owl-bot-staging/v1beta2/.mocharc.js deleted file mode 100644 index 50bc7f792..000000000 --- a/owl-bot-staging/v1beta2/.mocharc.js +++ /dev/null @@ -1,33 +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. -// -// ** 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/v1beta2/.prettierrc.js b/owl-bot-staging/v1beta2/.prettierrc.js deleted file mode 100644 index 84f4713a0..000000000 --- a/owl-bot-staging/v1beta2/.prettierrc.js +++ /dev/null @@ -1,22 +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. -// -// ** 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/v1beta2/README.md b/owl-bot-staging/v1beta2/README.md deleted file mode 100644 index f41eef852..000000000 --- a/owl-bot-staging/v1beta2/README.md +++ /dev/null @@ -1 +0,0 @@ -Documentai: Nodejs Client diff --git a/owl-bot-staging/v1beta2/linkinator.config.json b/owl-bot-staging/v1beta2/linkinator.config.json deleted file mode 100644 index 29a223b6d..000000000 --- a/owl-bot-staging/v1beta2/linkinator.config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io" - ], - "silent": true, - "concurrency": 10 -} diff --git a/owl-bot-staging/v1beta2/package.json b/owl-bot-staging/v1beta2/package.json deleted file mode 100644 index 0e76de79e..000000000 --- a/owl-bot-staging/v1beta2/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/documentai", - "version": "0.1.0", - "description": "Documentai client for Node.js", - "repository": "googleapis/nodejs-documentai", - "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 documentai", - "documentai", - "document understanding service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.19.0" - }, - "devDependencies": { - "@types/mocha": "^9.0.0", - "@types/node": "^14.17.3", - "@types/sinon": "^10.0.2", - "c8": "^7.7.3", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.0", - "jsdoc-region-tag": "^1.1.0", - "linkinator": "^2.13.6", - "mocha": "^9.0.2", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^11.1.1", - "ts-loader": "^9.2.3", - "typescript": "^4.3.4", - "webpack": "^5.39.1", - "webpack-cli": "^4.7.2" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto b/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto deleted file mode 100644 index bb3b58bad..000000000 --- a/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto +++ /dev/null @@ -1,519 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta2; - -import "google/api/field_behavior.proto"; -import "google/cloud/documentai/v1beta2/geometry.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta2;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentProto"; -option java_package = "com.google.cloud.documentai.v1beta2"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta2"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta2"; - -// Document represents the canonical document resource in Document Understanding -// AI. -// It is an interchange format that provides insights into documents and allows -// for collaboration between users and Document Understanding 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.v1beta2.Document.text] in the overall - // document global text. - int64 text_offset = 3; - } - - // Label attaches schema information and/or other metadata to segments within - // a [Document][google.cloud.documentai.v1beta2.Document]. Multiple [Label][google.cloud.documentai.v1beta2.Document.Label]s on a single field can denote either - // different labels, different instances of the same label created at - // different times, or some combination of both. - message Label { - // Provenance of the label. - oneof source { - // Label is generated AutoML model. This field stores the full resource - // name of the AutoML model. - // - // Format: - // `projects/{project-id}/locations/{location-id}/models/{model-id}` - string automl_model = 2; - } - - // Name of the label. - // - // When the label is generated from AutoML Text Classification model, this - // field represents the name of the category. - string name = 1; - - // Confidence score between 0 and 1 for label assignment. - float confidence = 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.v1beta2.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; - } - - // A page in a [Document][google.cloud.documentai.v1beta2.Document]. - message Page { - // Dimension for the page. - message Dimension { - // Page width. - float width = 1; - - // Page height. - float height = 2; - - // Dimension unit. - string unit = 3; - } - - // 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.v1beta2.Document.text]. - TextAnchor text_anchor = 1; - - // Confidence of the current [Layout][google.cloud.documentai.v1beta2.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.v1beta2.Document.Page.Layout]. - BoundingPoly bounding_poly = 3; - - // Detected orientation for the [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout]. - Orientation orientation = 4; - - // Optional. This is the identifier used by referencing [PageAnchor][google.cloud.documentai.v1beta2.Document.PageAnchor]s. - string id = 5 [(google.api.field_behavior) = OPTIONAL]; - } - - // A block has a set of lines (collected into paragraphs) that have a - // common line-spacing and orientation. - message Block { - // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [Block][google.cloud.documentai.v1beta2.Document.Page.Block]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - } - - // A collection of lines that a human would perceive as a paragraph. - message Paragraph { - // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1beta2.Document.Page.Paragraph]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - } - - // 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.v1beta2.Document.Page.Layout] for [Line][google.cloud.documentai.v1beta2.Document.Page.Line]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - } - - // A detected token. - message Token { - // Detected break at the end of a [Token][google.cloud.documentai.v1beta2.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.v1beta2.Document.Page.Layout] for [Token][google.cloud.documentai.v1beta2.Document.Page.Token]. - Layout layout = 1; - - // Detected break at the end of a [Token][google.cloud.documentai.v1beta2.Document.Page.Token]. - DetectedBreak detected_break = 2; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 3; - } - - // Detected non-text visual elements e.g. checkbox, signature etc. on the - // page. - message VisualElement { - // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1beta2.Document.Page.VisualElement]. - Layout layout = 1; - - // Type of the [VisualElement][google.cloud.documentai.v1beta2.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.v1beta2.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1beta2.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.v1beta2.Document.Page.Layout] for [Table][google.cloud.documentai.v1beta2.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; - } - - // A form field detected on the page. - message FormField { - // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta2.Document.Page.FormField] name. e.g. `Address`, `Email`, - // `Grand total`, `Phone number`, etc. - Layout field_name = 1; - - // [Layout][google.cloud.documentai.v1beta2.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta2.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; - - // An internal field, created for Labeling UI to export key text. - string corrected_key_text = 6; - - // An internal field, created for Labeling UI to export value text. - string corrected_value_text = 7; - } - - // Detected language for a structural component. - message DetectedLanguage { - // The BCP-47 language code, such as "en-US" or "sr-Latn". For more - // information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 1; - - // Confidence of detected language. Range [0, 1]. - float confidence = 2; - } - - // 1-based index for current [Page][google.cloud.documentai.v1beta2.Document.Page] in a parent [Document][google.cloud.documentai.v1beta2.Document]. - // Useful when a page is taken out of a [Document][google.cloud.documentai.v1beta2.Document] for individual - // processing. - int32 page_number = 1; - - // Physical dimension of the page. - Dimension dimension = 2; - - // [Layout][google.cloud.documentai.v1beta2.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 phrase in the text that is a known entity type, such as a person, an - // organization, or location. - message Entity { - // Provenance of the entity. - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta2.Document.text]. - TextAnchor text_anchor = 1; - - // Entity type from a schema e.g. `Address`. - string type = 2; - - // Text value in the document e.g. `1600 Amphitheatre Pkwy`. - string mention_text = 3; - - // Deprecated. Use `id` field instead. - string mention_id = 4; - - // 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. Temporary field to store the bounding poly for short-term POCs. Used by - // the frontend only. Do not use before you talk to ybo@ and lukasr@. - BoundingPoly bounding_poly_for_demo_frontend = 8 [(google.api.field_behavior) = OPTIONAL]; - } - - // Relationship between [Entities][google.cloud.documentai.v1beta2.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.v1beta2.Document.text]. - message TextAnchor { - // A text segment in the [Document.text][google.cloud.documentai.v1beta2.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.v1beta2.Document.ShardInfo.text_offset] - message TextSegment { - // [TextSegment][google.cloud.documentai.v1beta2.Document.TextAnchor.TextSegment] start UTF-8 char index in the [Document.text][google.cloud.documentai.v1beta2.Document.text]. - int64 start_index = 1; - - // [TextSegment][google.cloud.documentai.v1beta2.Document.TextAnchor.TextSegment] half open end UTF-8 char index in the - // [Document.text][google.cloud.documentai.v1beta2.Document.text]. - int64 end_index = 2; - } - - // The text segments from the [Document.text][google.cloud.documentai.v1beta2.Document.text]. - repeated TextSegment text_segments = 1; - } - - // Referencing elements in [Document.pages][google.cloud.documentai.v1beta2.Document.pages]. - 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.v1beta2.Document.Page.blocks] element. - BLOCK = 1; - - // References a [Page.paragraphs][google.cloud.documentai.v1beta2.Document.Page.paragraphs] element. - PARAGRAPH = 2; - - // References a [Page.lines][google.cloud.documentai.v1beta2.Document.Page.lines] element. - LINE = 3; - - // References a [Page.tokens][google.cloud.documentai.v1beta2.Document.Page.tokens] element. - TOKEN = 4; - - // References a [Page.visual_elements][google.cloud.documentai.v1beta2.Document.Page.visual_elements] element. - VISUAL_ELEMENT = 5; - - // Refrrences a [Page.tables][google.cloud.documentai.v1beta2.Document.Page.tables] element. - TABLE = 6; - - // References a [Page.form_fields][google.cloud.documentai.v1beta2.Document.Page.form_fields] element. - FORM_FIELD = 7; - } - - // Required. Index into the [Document.pages][google.cloud.documentai.v1beta2.Document.pages] element - int64 page = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The type of the layout element that is being referenced. If not - // specified the whole page is assumed to be referenced. - LayoutType layout_type = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The [Page.Layout.id][google.cloud.documentai.v1beta2.Document.Page.Layout.id] on the page that this element - // references. If [LayoutRef.type][] is specified this id must also be - // specified. - string layout_id = 3 [(google.api.field_behavior) = OPTIONAL]; - } - - // One or more references to visual page elements - repeated PageRef page_refs = 1; - } - - // Original source document from the user. - oneof source { - // 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; - - // 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; - } - - // 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; - - // UTF-8 encoded text in reading order from the document. - string text = 4; - - // Styles for the [Document.text][google.cloud.documentai.v1beta2.Document.text]. - repeated Style text_styles = 5; - - // Visual page layout for the [Document][google.cloud.documentai.v1beta2.Document]. - repeated Page pages = 6; - - // A list of entities detected on [Document.text][google.cloud.documentai.v1beta2.Document.text]. For document shards, - // entities in this list may cross shard boundaries. - repeated Entity entities = 7; - - // Relationship among [Document.entities][google.cloud.documentai.v1beta2.Document.entities]. - repeated EntityRelation entity_relations = 8; - - // 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; - - // [Label][google.cloud.documentai.v1beta2.Document.Label]s for this document. - repeated Label labels = 11; - - // Any error that occurred while processing this document. - google.rpc.Status error = 10; -} diff --git a/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto b/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto deleted file mode 100644 index 137ba5e31..000000000 --- a/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto +++ /dev/null @@ -1,346 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/cloud/documentai/v1beta2/document.proto"; -import "google/cloud/documentai/v1beta2/geometry.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta2;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProto"; -option java_package = "com.google.cloud.documentai.v1beta2"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta2"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta2"; - -// Service to parse structured information from unstructured or semi-structured -// documents using state-of-the-art Google AI such as natural language, -// computer vision, and translation. -service DocumentUnderstandingService { - option (google.api.default_host) = "documentai.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // LRO endpoint to batch process many documents. The output is written - // to Cloud Storage as JSON in the [Document] format. - rpc BatchProcessDocuments(BatchProcessDocumentsRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta2/{parent=projects/*/locations/*}/documents:batchProcess" - body: "*" - additional_bindings { - post: "/v1beta2/{parent=projects/*}/documents:batchProcess" - body: "*" - } - }; - option (google.api.method_signature) = "requests"; - option (google.longrunning.operation_info) = { - response_type: "BatchProcessDocumentsResponse" - metadata_type: "OperationMetadata" - }; - } - - // Processes a single document. - rpc ProcessDocument(ProcessDocumentRequest) returns (Document) { - option (google.api.http) = { - post: "/v1beta2/{parent=projects/*/locations/*}/documents:process" - body: "*" - additional_bindings { - post: "/v1beta2/{parent=projects/*}/documents:process" - body: "*" - } - }; - } -} - -// Request to batch process documents as an asynchronous operation. The output -// is written to Cloud Storage as JSON in the [Document] format. -message BatchProcessDocumentsRequest { - // Required. Individual requests for each document. - repeated ProcessDocumentRequest requests = 1 [(google.api.field_behavior) = REQUIRED]; - - // Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no location is specified, a region will be chosen automatically. - string parent = 2; -} - -// Request to process one document. -message ProcessDocumentRequest { - // Target project and location to make a call. - // - // Format: `projects/{project-id}/locations/{location-id}`. - // - // If no location is specified, a region will be chosen automatically. - // This field is only populated when used in ProcessDocument method. - string parent = 9; - - // Required. Information about the input file. - InputConfig input_config = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The desired output location. This field is only needed in - // BatchProcessDocumentsRequest. - OutputConfig output_config = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Specifies a known document type for deeper structure detection. Valid - // values are currently "general" and "invoice". If not provided, "general"\ - // is used as default. If any other value is given, the request is rejected. - string document_type = 3; - - // Controls table extraction behavior. If not specified, the system will - // decide reasonable defaults. - TableExtractionParams table_extraction_params = 4; - - // Controls form extraction behavior. If not specified, the system will - // decide reasonable defaults. - FormExtractionParams form_extraction_params = 5; - - // Controls entity extraction behavior. If not specified, the system will - // decide reasonable defaults. - EntityExtractionParams entity_extraction_params = 6; - - // Controls OCR behavior. If not specified, the system will decide reasonable - // defaults. - OcrParams ocr_params = 7; - - // Controls AutoML model prediction behavior. AutoMlParams cannot be used - // together with other Params. - AutoMlParams automl_params = 8; -} - -// Response to an batch document processing request. This is returned in -// the LRO Operation after the operation is complete. -message BatchProcessDocumentsResponse { - // Responses for each individual document. - repeated ProcessDocumentResponse responses = 1; -} - -// Response to a single document processing request. -message ProcessDocumentResponse { - // Information about the input file. This is the same as the corresponding - // input config in the request. - InputConfig input_config = 1; - - // The output location of the parsed responses. The responses are written to - // this location as JSON-serialized `Document` objects. - OutputConfig output_config = 2; -} - -// Parameters to control Optical Character Recognition (OCR) behavior. -message OcrParams { - // List of languages to use for OCR. In most cases, an empty value - // yields the best results since it enables automatic language detection. For - // languages based on the Latin alphabet, setting `language_hints` is not - // needed. In rare cases, when the language of the text in the image is known, - // setting a hint will help get better results (although it will be a - // significant hindrance if the hint is wrong). Document processing returns an - // error if one or more of the specified languages is not one of the - // supported languages. - repeated string language_hints = 1; -} - -// Parameters to control table extraction behavior. -message TableExtractionParams { - // Whether to enable table extraction. - bool enabled = 1; - - // Optional. Table bounding box hints that can be provided to complex cases - // which our algorithm cannot locate the table(s) in. - repeated TableBoundHint table_bound_hints = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Table header hints. The extraction will bias towards producing - // these terms as table headers, which may improve accuracy. - repeated string header_hints = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Model version of the table extraction system. Default is "builtin/stable". - // Specify "builtin/latest" for the latest model. - string model_version = 4; -} - -// A hint for a table bounding box on the page for table parsing. -message TableBoundHint { - // Optional. Page number for multi-paged inputs this hint applies to. If not - // provided, this hint will apply to all pages by default. This value is - // 1-based. - int32 page_number = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Bounding box hint for a table on this page. The coordinates must be - // normalized to [0,1] and the bounding box must be an axis-aligned rectangle. - BoundingPoly bounding_box = 2; -} - -// Parameters to control form extraction behavior. -message FormExtractionParams { - // Whether to enable form extraction. - bool enabled = 1; - - // User can provide pairs of (key text, value type) to improve the parsing - // result. - // - // For example, if a document has a field called "Date" that holds a date - // value and a field called "Amount" that may hold either a currency value - // (e.g., "$500.00") or a simple number value (e.g., "20"), you could use the - // following hints: [ {"key": "Date", value_types: [ "DATE"]}, {"key": - // "Amount", "value_types": [ "PRICE", "NUMBER" ]} ] - // - // If the value type is unknown, but you want to provide hints for the keys, - // you can leave the value_types field blank. e.g. {"key": "Date", - // "value_types": []} - repeated KeyValuePairHint key_value_pair_hints = 2; - - // Model version of the form extraction system. Default is - // "builtin/stable". Specify "builtin/latest" for the latest model. - // For custom form models, specify: “custom/{model_name}". Model name - // format is "bucket_name/path/to/modeldir" corresponding to - // "gs://bucket_name/path/to/modeldir" where annotated examples are stored. - string model_version = 3; -} - -// User-provided hint for key value pair. -message KeyValuePairHint { - // The key text for the hint. - string key = 1; - - // Type of the value. This is case-insensitive, and could be one of: - // ADDRESS, LOCATION, ORGANIZATION, PERSON, PHONE_NUMBER, - // ID, NUMBER, EMAIL, PRICE, TERMS, DATE, NAME. Types not in this list will - // be ignored. - repeated string value_types = 2; -} - -// Parameters to control entity extraction behavior. -message EntityExtractionParams { - // Whether to enable entity extraction. - bool enabled = 1; - - // Model version of the entity extraction. Default is - // "builtin/stable". Specify "builtin/latest" for the latest model. - string model_version = 2; -} - -// Parameters to control AutoML model prediction behavior. -message AutoMlParams { - // Resource name of the AutoML model. - // - // Format: `projects/{project-id}/locations/{location-id}/models/{model-id}`. - string model = 1; -} - -// The desired input location and metadata. -message InputConfig { - // Required. - oneof source { - // The Google Cloud Storage location to read the input from. This must be a - // single file. - GcsSource gcs_source = 1; - - // Content in bytes, represented as a stream of bytes. - // Note: As with all `bytes` fields, proto buffer messages use a pure binary - // representation, whereas JSON representations use base64. - // - // This field only works for synchronous ProcessDocument method. - bytes contents = 3; - } - - // Required. Mimetype of the input. Current supported mimetypes are application/pdf, - // image/tiff, and image/gif. - // In addition, application/json type is supported for requests with - // [ProcessDocumentRequest.automl_params][google.cloud.documentai.v1beta2.ProcessDocumentRequest.automl_params] field set. The JSON file needs to - // be in [Document][google.cloud.documentai.v1beta2.Document] format. - string mime_type = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The desired output location and metadata. -message OutputConfig { - // Required. - oneof destination { - // The Google Cloud Storage location to write the output to. - GcsDestination gcs_destination = 1; - } - - // The max number of pages to include into each output Document shard JSON on - // Google Cloud Storage. - // - // The valid range is [1, 100]. If not specified, the default value is 20. - // - // For example, for one pdf file with 100 pages, 100 parsed pages will be - // produced. If `pages_per_shard` = 20, then 5 Document shard JSON files each - // containing 20 parsed pages will be written under the prefix - // [OutputConfig.gcs_destination.uri][] and suffix pages-x-to-y.json where - // x and y are 1-indexed page numbers. - // - // Example GCS outputs with 157 pages and pages_per_shard = 50: - // - // pages-001-to-050.json - // pages-051-to-100.json - // pages-101-to-150.json - // pages-151-to-157.json - int32 pages_per_shard = 2; -} - -// The Google Cloud Storage location where the input file will be read from. -message GcsSource { - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The Google Cloud Storage location where the output file will be written to. -message GcsDestination { - string uri = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Contains metadata for the BatchProcessDocuments operation. -message OperationMetadata { - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // Request is received. - ACCEPTED = 1; - - // Request operation is waiting for scheduling. - WAITING = 2; - - // Request is being processed. - RUNNING = 3; - - // The batch processing completed successfully. - SUCCEEDED = 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. - 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; -} diff --git a/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto b/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto deleted file mode 100644 index 6aff4db8c..000000000 --- a/owl-bot-staging/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta2; - -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta2"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta2;documentai"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.documentai.v1beta2"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta2"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta2"; - -// 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. - 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. - 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/v1beta2/src/index.ts b/owl-bot-staging/v1beta2/src/index.ts deleted file mode 100644 index 446ae879d..000000000 --- a/owl-bot-staging/v1beta2/src/index.ts +++ /dev/null @@ -1,25 +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. -// -// ** 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 v1beta2 from './v1beta2'; -const DocumentUnderstandingServiceClient = v1beta2.DocumentUnderstandingServiceClient; -type DocumentUnderstandingServiceClient = v1beta2.DocumentUnderstandingServiceClient; -export {v1beta2, DocumentUnderstandingServiceClient}; -export default {v1beta2, DocumentUnderstandingServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client.ts b/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client.ts deleted file mode 100644 index d113355b6..000000000 --- a/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client.ts +++ /dev/null @@ -1,516 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta2/document_understanding_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './document_understanding_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Service to parse structured information from unstructured or semi-structured - * documents using state-of-the-art Google AI such as natural language, - * computer vision, and translation. - * @class - * @memberof v1beta2 - */ -export class DocumentUnderstandingServiceClient { - 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}; - operationsClient: gax.OperationsClient; - documentUnderstandingServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DocumentUnderstandingServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DocumentUnderstandingServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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); - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const batchProcessDocumentsResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta2.BatchProcessDocumentsResponse') as gax.protobuf.Type; - const batchProcessDocumentsMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta2.OperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - batchProcessDocumentsResponse.decode.bind(batchProcessDocumentsResponse), - batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.documentai.v1beta2.DocumentUnderstandingService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.documentUnderstandingServiceStub) { - return this.documentUnderstandingServiceStub; - } - - // Put together the "service stub" for - // google.cloud.documentai.v1beta2.DocumentUnderstandingService. - this.documentUnderstandingServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.documentai.v1beta2.DocumentUnderstandingService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.documentai.v1beta2.DocumentUnderstandingService, - 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 documentUnderstandingServiceStubMethods = - ['batchProcessDocuments', 'processDocument']; - for (const methodName of documentUnderstandingServiceStubMethods) { - const callPromise = this.documentUnderstandingServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.documentUnderstandingServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'documentai.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 'documentai.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 -- - // ------------------- - processDocument( - request?: protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta2.IDocument, - protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|undefined, {}|undefined - ]>; - processDocument( - request: protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1beta2.IDocument, - protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|null|undefined, - {}|null|undefined>): void; - processDocument( - request: protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest, - callback: Callback< - protos.google.cloud.documentai.v1beta2.IDocument, - protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|null|undefined, - {}|null|undefined>): void; -/** - * Processes a single document. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no location is specified, a region will be chosen automatically. - * This field is only populated when used in ProcessDocument method. - * @param {google.cloud.documentai.v1beta2.InputConfig} request.inputConfig - * Required. Information about the input file. - * @param {google.cloud.documentai.v1beta2.OutputConfig} [request.outputConfig] - * Optional. The desired output location. This field is only needed in - * BatchProcessDocumentsRequest. - * @param {string} request.documentType - * Specifies a known document type for deeper structure detection. Valid - * values are currently "general" and "invoice". If not provided, "general"\ - * is used as default. If any other value is given, the request is rejected. - * @param {google.cloud.documentai.v1beta2.TableExtractionParams} request.tableExtractionParams - * Controls table extraction behavior. If not specified, the system will - * decide reasonable defaults. - * @param {google.cloud.documentai.v1beta2.FormExtractionParams} request.formExtractionParams - * Controls form extraction behavior. If not specified, the system will - * decide reasonable defaults. - * @param {google.cloud.documentai.v1beta2.EntityExtractionParams} request.entityExtractionParams - * Controls entity extraction behavior. If not specified, the system will - * decide reasonable defaults. - * @param {google.cloud.documentai.v1beta2.OcrParams} request.ocrParams - * Controls OCR behavior. If not specified, the system will decide reasonable - * defaults. - * @param {google.cloud.documentai.v1beta2.AutoMlParams} request.automlParams - * Controls AutoML model prediction behavior. AutoMlParams cannot be used - * together with other Params. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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.documentai.v1beta2.Document}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.processDocument(request); - */ - processDocument( - request?: protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1beta2.IDocument, - protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1beta2.IDocument, - protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1beta2.IDocument, - protos.google.cloud.documentai.v1beta2.IProcessDocumentRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.processDocument(request, options, callback); - } - - batchProcessDocuments( - request?: protos.google.cloud.documentai.v1beta2.IBatchProcessDocumentsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - batchProcessDocuments( - request: protos.google.cloud.documentai.v1beta2.IBatchProcessDocumentsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - batchProcessDocuments( - request: protos.google.cloud.documentai.v1beta2.IBatchProcessDocumentsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * LRO endpoint to batch process many documents. The output is written - * to Cloud Storage as JSON in the [Document] format. - * - * @param {Object} request - * The request object that will be sent. - * @param {number[]} request.requests - * Required. Individual requests for each document. - * @param {string} request.parent - * Target project and location to make a call. - * - * Format: `projects/{project-id}/locations/{location-id}`. - * - * If no location is specified, a region will be chosen automatically. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.batchProcessDocuments(request); - * const [response] = await operation.promise(); - */ - batchProcessDocuments( - request?: protos.google.cloud.documentai.v1beta2.IBatchProcessDocumentsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.batchProcessDocuments(request, options, callback); - } -/** - * Check the status of the long running operation returned by `batchProcessDocuments()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkBatchProcessDocumentsProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkBatchProcessDocumentsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - - /** - * 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 { - this.initialize(); - if (!this._terminated) { - return this.documentUnderstandingServiceStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client_config.json b/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client_config.json deleted file mode 100644 index 1dea85e96..000000000 --- a/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_client_config.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "interfaces": { - "google.cloud.documentai.v1beta2.DocumentUnderstandingService": { - "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": { - "BatchProcessDocuments": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ProcessDocument": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_proto_list.json b/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_proto_list.json deleted file mode 100644 index ee1f3779a..000000000 --- a/owl-bot-staging/v1beta2/src/v1beta2/document_understanding_service_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/cloud/documentai/v1beta2/document.proto", - "../../protos/google/cloud/documentai/v1beta2/document_understanding.proto", - "../../protos/google/cloud/documentai/v1beta2/geometry.proto" -] diff --git a/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json b/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json deleted file mode 100644 index 49efed8a7..000000000 --- a/owl-bot-staging/v1beta2/src/v1beta2/gapic_metadata.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.documentai.v1beta2", - "libraryPackage": "@google-cloud/documentai", - "services": { - "DocumentUnderstandingService": { - "clients": { - "grpc": { - "libraryClient": "DocumentUnderstandingServiceClient", - "rpcs": { - "ProcessDocument": { - "methods": [ - "processDocument" - ] - }, - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentUnderstandingServiceClient", - "rpcs": { - "ProcessDocument": { - "methods": [ - "processDocument" - ] - }, - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1beta2/src/v1beta2/index.ts b/owl-bot-staging/v1beta2/src/v1beta2/index.ts deleted file mode 100644 index 1a00861f8..000000000 --- a/owl-bot-staging/v1beta2/src/v1beta2/index.ts +++ /dev/null @@ -1,19 +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. -// -// ** 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 {DocumentUnderstandingServiceClient} from './document_understanding_service_client'; diff --git a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 027cdf0f1..000000000 --- a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +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. -// -// ** 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 documentai = require('@google-cloud/documentai'); - -function main() { - const documentUnderstandingServiceClient = new documentai.DocumentUnderstandingServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index ea46db1aa..000000000 --- a/owl-bot-staging/v1beta2/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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. -// -// ** 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 {DocumentUnderstandingServiceClient} from '@google-cloud/documentai'; - -// check that the client class type name can be used -function doStuffWithDocumentUnderstandingServiceClient(client: DocumentUnderstandingServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const documentUnderstandingServiceClient = new DocumentUnderstandingServiceClient(); - doStuffWithDocumentUnderstandingServiceClient(documentUnderstandingServiceClient); -} - -main(); diff --git a/owl-bot-staging/v1beta2/system-test/install.ts b/owl-bot-staging/v1beta2/system-test/install.ts deleted file mode 100644 index 1f850b522..000000000 --- a/owl-bot-staging/v1beta2/system-test/install.ts +++ /dev/null @@ -1,49 +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. -// -// ** 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/v1beta2/test/gapic_document_understanding_service_v1beta2.ts b/owl-bot-staging/v1beta2/test/gapic_document_understanding_service_v1beta2.ts deleted file mode 100644 index fb1d18335..000000000 --- a/owl-bot-staging/v1beta2/test/gapic_document_understanding_service_v1beta2.ts +++ /dev/null @@ -1,364 +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. -// -// ** 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 documentunderstandingserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1beta2.DocumentUnderstandingServiceClient', () => { - it('has servicePath', () => { - const servicePath = documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentUnderstandingServiceStub, undefined); - await client.initialize(); - assert(client.documentUnderstandingServiceStub); - }); - - it('has close method', () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - 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 documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - 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('processDocument', () => { - it('invokes processDocument without error', async () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.ProcessDocumentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.Document()); - client.innerApiCalls.processDocument = stubSimpleCall(expectedResponse); - const [response] = await client.processDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.processDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes processDocument without error using callback', async () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.ProcessDocumentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.Document()); - client.innerApiCalls.processDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.processDocument( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1beta2.IDocument|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.processDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes processDocument with error', async () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.ProcessDocumentRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.processDocument(request), expectedError); - assert((client.innerApiCalls.processDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('batchProcessDocuments', () => { - it('invokes batchProcessDocuments without error', async () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchProcessDocuments(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchProcessDocuments without error using callback', async () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchProcessDocuments( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchProcessDocuments with call error', async () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchProcessDocuments(request), expectedError); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchProcessDocuments with LRO error', async () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchProcessDocuments(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkBatchProcessDocumentsProgress without error', async () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchProcessDocumentsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkBatchProcessDocumentsProgress with error', async () => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchProcessDocumentsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); -}); diff --git a/owl-bot-staging/v1beta2/tsconfig.json b/owl-bot-staging/v1beta2/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/v1beta2/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/v1beta2/webpack.config.js b/owl-bot-staging/v1beta2/webpack.config.js deleted file mode 100644 index c6fdde565..000000000 --- a/owl-bot-staging/v1beta2/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: 'DocumentUnderstandingService', - filename: './document-understanding-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/owl-bot-staging/v1beta3/.eslintignore b/owl-bot-staging/v1beta3/.eslintignore deleted file mode 100644 index 521dc25a2..000000000 --- a/owl-bot-staging/v1beta3/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ diff --git a/owl-bot-staging/v1beta3/.eslintrc.json b/owl-bot-staging/v1beta3/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/v1beta3/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1beta3/.gitignore b/owl-bot-staging/v1beta3/.gitignore deleted file mode 100644 index 5d32b2378..000000000 --- a/owl-bot-staging/v1beta3/.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/v1beta3/.jsdoc.js b/owl-bot-staging/v1beta3/.jsdoc.js deleted file mode 100644 index a00b08ce2..000000000 --- a/owl-bot-staging/v1beta3/.jsdoc.js +++ /dev/null @@ -1,55 +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. -// -// ** This file 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 2021 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/documentai', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1beta3/.mocharc.js b/owl-bot-staging/v1beta3/.mocharc.js deleted file mode 100644 index 50bc7f792..000000000 --- a/owl-bot-staging/v1beta3/.mocharc.js +++ /dev/null @@ -1,33 +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. -// -// ** 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/v1beta3/.prettierrc.js b/owl-bot-staging/v1beta3/.prettierrc.js deleted file mode 100644 index 84f4713a0..000000000 --- a/owl-bot-staging/v1beta3/.prettierrc.js +++ /dev/null @@ -1,22 +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. -// -// ** 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/v1beta3/README.md b/owl-bot-staging/v1beta3/README.md deleted file mode 100644 index f41eef852..000000000 --- a/owl-bot-staging/v1beta3/README.md +++ /dev/null @@ -1 +0,0 @@ -Documentai: Nodejs Client diff --git a/owl-bot-staging/v1beta3/linkinator.config.json b/owl-bot-staging/v1beta3/linkinator.config.json deleted file mode 100644 index 29a223b6d..000000000 --- a/owl-bot-staging/v1beta3/linkinator.config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io" - ], - "silent": true, - "concurrency": 10 -} diff --git a/owl-bot-staging/v1beta3/package.json b/owl-bot-staging/v1beta3/package.json deleted file mode 100644 index 57616ace7..000000000 --- a/owl-bot-staging/v1beta3/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/documentai", - "version": "0.1.0", - "description": "Documentai client for Node.js", - "repository": "googleapis/nodejs-documentai", - "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 documentai", - "documentai", - "document processor service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.19.0" - }, - "devDependencies": { - "@types/mocha": "^9.0.0", - "@types/node": "^14.17.3", - "@types/sinon": "^10.0.2", - "c8": "^7.7.3", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.0", - "jsdoc-region-tag": "^1.1.0", - "linkinator": "^2.13.6", - "mocha": "^9.0.2", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^11.1.1", - "ts-loader": "^9.2.3", - "typescript": "^4.3.4", - "webpack": "^5.39.1", - "webpack-cli": "^4.7.2" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto deleted file mode 100644 index abba3ae19..000000000 --- a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto +++ /dev/null @@ -1,730 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -import "google/api/field_behavior.proto"; -import "google/cloud/documentai/v1beta3/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"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentProto"; -option java_package = "com.google.cloud.documentai.v1beta3"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; - -// Document represents the canonical document resource in Document Understanding -// AI. -// It is an interchange format that provides insights into documents and allows -// for collaboration between users and Document Understanding 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.v1beta3.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.v1beta3.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; - } - - // A page in a [Document][google.cloud.documentai.v1beta3.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.v1beta3.Document.text]. - TextAnchor text_anchor = 1; - - // Confidence of the current [Layout][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.Layout]. - BoundingPoly bounding_poly = 3; - - // Detected orientation for the [Layout][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.Layout] for [Block][google.cloud.documentai.v1beta3.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; - } - - // A collection of lines that a human would perceive as a paragraph. - message Paragraph { - // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1beta3.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; - } - - // 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.v1beta3.Document.Page.Layout] for [Line][google.cloud.documentai.v1beta3.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; - } - - // A detected token. - message Token { - // Detected break at the end of a [Token][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.Layout] for [Token][google.cloud.documentai.v1beta3.Document.Page.Token]. - Layout layout = 1; - - // Detected break at the end of a [Token][google.cloud.documentai.v1beta3.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; - } - - // Detected non-text visual elements e.g. checkbox, signature etc. on the - // page. - message VisualElement { - // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1beta3.Document.Page.VisualElement]. - Layout layout = 1; - - // Type of the [VisualElement][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.Layout] for [Table][google.cloud.documentai.v1beta3.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; - } - - // A form field detected on the page. - message FormField { - // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta3.Document.Page.FormField] name. e.g. `Address`, `Email`, - // `Grand total`, `Phone number`, etc. - Layout field_name = 1; - - // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1beta3.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; - - // The history of this annotation. - Provenance provenance = 8; - } - - // Detected language for a structural component. - message DetectedLanguage { - // The BCP-47 language code, such as "en-US" or "sr-Latn". For more - // information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 1; - - // Confidence of detected language. Range [0, 1]. - float confidence = 2; - } - - // 1-based index for current [Page][google.cloud.documentai.v1beta3.Document.Page] in a parent [Document][google.cloud.documentai.v1beta3.Document]. - // Useful when a page is taken out of a [Document][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.image]. - repeated Matrix transforms = 14; - - // Physical dimension of the page. - Dimension dimension = 2; - - // [Layout][google.cloud.documentai.v1beta3.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; - - // The history of this page. - Provenance provenance = 16; - } - - // A phrase in the text that is a known entity type, such as a person, an - // organization, or location. - message Entity { - // Parsed and normalized entity value. - message NormalizedValue { - // Structured entity value. Must match entity type defined in schema if - // known. If this field is present, the 'text' field is still 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; - } - - // Required. Normalized entity value stored as a string. This field is populated for - // supported document type (e.g. Invoice). For some entity types, one of - // respective 'structured_value' fields may also be populated. - // - // - 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) = REQUIRED]; - } - - // Optional. Provenance of the entity. - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta3.Document.text]. - TextAnchor text_anchor = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Entity type from a schema e.g. `Address`. - string type = 2; - - // Optional. Text value in the document 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.v1beta3.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.v1beta3.Document.text]. - message TextAnchor { - // A text segment in the [Document.text][google.cloud.documentai.v1beta3.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.v1beta3.Document.ShardInfo.text_offset] - message TextSegment { - // [TextSegment][google.cloud.documentai.v1beta3.Document.TextAnchor.TextSegment] start UTF-8 char index in the [Document.text][google.cloud.documentai.v1beta3.Document.text]. - int64 start_index = 1; - - // [TextSegment][google.cloud.documentai.v1beta3.Document.TextAnchor.TextSegment] half open end UTF-8 char index in the - // [Document.text][google.cloud.documentai.v1beta3.Document.text]. - int64 end_index = 2; - } - - // The text segments from the [Document.text][google.cloud.documentai.v1beta3.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. - string content = 2; - } - - // Referencing the visual context of the entity in the [Document.pages][google.cloud.documentai.v1beta3.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.v1beta3.Document.Page.blocks] element. - BLOCK = 1; - - // References a [Page.paragraphs][google.cloud.documentai.v1beta3.Document.Page.paragraphs] element. - PARAGRAPH = 2; - - // References a [Page.lines][google.cloud.documentai.v1beta3.Document.Page.lines] element. - LINE = 3; - - // References a [Page.tokens][google.cloud.documentai.v1beta3.Document.Page.tokens] element. - TOKEN = 4; - - // References a [Page.visual_elements][google.cloud.documentai.v1beta3.Document.Page.visual_elements] element. - VISUAL_ELEMENT = 5; - - // Refrrences a [Page.tables][google.cloud.documentai.v1beta3.Document.Page.tables] element. - TABLE = 6; - - // References a [Page.form_fields][google.cloud.documentai.v1beta3.Document.Page.form_fields] element. - FORM_FIELD = 7; - } - - // Required. Index into the [Document.pages][google.cloud.documentai.v1beta3.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.v1beta3.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 { - // Structure for referencing parent provenances. When an element replaces - // one of more other elements parent references identify the elements that - // are replaced. - message Parent { - // The index of the [Document.revisions] identifying the parent revision. - int32 revision = 1; - - // The index of the parent revisions corresponding collection of items - // (eg. list of entities, properties within entities, etc.) - 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. - OPERATION_TYPE_UNSPECIFIED = 0; - - // Add an element. Implicit if no `parents` are set for the provenance. - ADD = 1; - - // The element is removed. No `parents` should be set. - REMOVE = 2; - - // Explicitly replaces the element(s) identified by `parents`. - REPLACE = 3; - - // Element is requested for human review. - 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; - - // 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.v1beta3.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; - } - - // 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]; - - // Styles for the [Document.text][google.cloud.documentai.v1beta3.Document.text]. - repeated Style text_styles = 5; - - // Visual page layout for the [Document][google.cloud.documentai.v1beta3.Document]. - repeated Page pages = 6; - - // A list of entities detected on [Document.text][google.cloud.documentai.v1beta3.Document.text]. For document shards, - // entities in this list may cross shard boundaries. - repeated Entity entities = 7; - - // Relationship among [Document.entities][google.cloud.documentai.v1beta3.Document.entities]. - repeated EntityRelation entity_relations = 8; - - // A list of text corrections made to [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; - - // Revision history of this document. - repeated Revision revisions = 13; -} diff --git a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto deleted file mode 100644 index d364d4aba..000000000 --- a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentIoProto"; -option java_package = "com.google.cloud.documentai.v1beta3"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; - -// 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]. - 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 Cloud Storage uri (a directory) of the output. - string gcs_uri = 1; - } - - // 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/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto deleted file mode 100644 index e76a03164..000000000 --- a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto +++ /dev/null @@ -1,572 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -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/v1beta3/document.proto"; -import "google/cloud/documentai/v1beta3/document_io.proto"; -import "google/cloud/documentai/v1beta3/operation_metadata.proto"; -import "google/cloud/documentai/v1beta3/processor.proto"; -import "google/cloud/documentai/v1beta3/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.V1Beta3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProcessorService"; -option java_package = "com.google.cloud.documentai.v1beta3"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; - -// (-- aip.dev/not-precedent: This is needed because we have references to -// these resources in our public API, but the resource management is not -// part of the public API (UI access only). So we have to define -// these resource here to avoid any "unable to find resources" error. --) -option (google.api.resource_definition) = { - type: "documentai.googleapis.com/Location" - pattern: "projects/{project}/locations/{location}" -}; -option (google.api.resource_definition) = { - type: "documentai.googleapis.com/HumanReviewConfig" - pattern: "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" -}; - -// 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: "/v1beta3/{name=projects/*/locations/*/processors/*}: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: "/v1beta3/{name=projects/*/locations/*/processors/*}:batchProcess" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "BatchProcessResponse" - metadata_type: "BatchProcessMetadata" - }; - } - - // Fetches processor types. - rpc FetchProcessorTypes(FetchProcessorTypesRequest) returns (FetchProcessorTypesResponse) { - option (google.api.http) = { - get: "/v1beta3/{parent=projects/*/locations/*}:fetchProcessorTypes" - }; - option (google.api.method_signature) = "parent"; - } - - // Lists all processors which belong to this project. - rpc ListProcessors(ListProcessorsRequest) returns (ListProcessorsResponse) { - option (google.api.http) = { - get: "/v1beta3/{parent=projects/*/locations/*}/processors" - }; - option (google.api.method_signature) = "parent"; - } - - // 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: "/v1beta3/{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: "/v1beta3/{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: "/v1beta3/{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: "/v1beta3/{name=projects/*/locations/*/processors/*}:disable" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "DisableProcessorResponse" - metadata_type: "DisableProcessorMetadata" - }; - } - - // 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: "/v1beta3/{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 processor resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; - - // The document payload, the [content] and [mime_type] fields must be set. - Document document = 2 [deprecated = true]; - - // Whether Human Review feature should be skipped for this request. Default to - // false. - bool skip_human_review = 3; -} - -// 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 name of the operation triggered by the processed document. If the human - // review process is not triggered, this field will be empty. It has the same - // response type and metadata as the long running operation returned by - // ReviewDocument method. - string human_review_operation = 2 [deprecated = true]; - - // The status of human review on the processed document. - HumanReviewStatus human_review_status = 3; -} - -// Request message for batch process document method. -message BatchProcessRequest { - // The message for input config in batch process. - message BatchInputConfig { - option deprecated = true; - - // The Cloud Storage location as the source of the document. - string gcs_source = 1; - - // Mimetype of the input. If the input is a raw document, the supported - // mimetypes are application/pdf, image/tiff, and image/gif. - // If the input is a [Document] proto, the type should be application/json. - string mime_type = 2; - } - - // The message for output config in batch process. - message BatchOutputConfig { - option deprecated = true; - - // The output Cloud Storage directory to put the processed documents. - string gcs_destination = 1; - } - - // Required. The processor resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; - - // The input config for each single document in the batch process. - repeated BatchInputConfig input_configs = 2 [deprecated = true]; - - // The overall output config for batch process. - BatchOutputConfig output_config = 3 [deprecated = true]; - - // 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 of the processing of 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 name of the operation triggered by the processed document. If the - // human review process is not triggered, this field will be empty. It has - // the same response type and metadata as the long running operation - // returned by ReviewDocument method. - string human_review_operation = 4 [deprecated = true]; - - // 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. - // 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 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 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. -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. -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 review document method. -// Next Id: 6. -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" - } - ]; - - // The document that needs human review. - Document document = 2 [deprecated = true]; - - // 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; -} - -// Response message for review document method. -message ReviewDocumentResponse { - // The Cloud Storage uri for the human reviewed document. - string gcs_destination = 1; -} - -// The long running operation metadata for review document method. -message ReviewDocumentOperationMetadata { - // 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; - } - - // Used only when Operation.done is false. - 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 basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} diff --git a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto deleted file mode 100644 index 91cd956ea..000000000 --- a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.documentai.v1beta3"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; - -// 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/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto deleted file mode 100644 index 1d8624e8f..000000000 --- a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto +++ /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 -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT 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.v1beta3; - -import "google/protobuf/timestamp.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; -option java_multiple_files = true; -option java_outer_classname = "OperationMetadataProto"; -option java_package = "com.google.cloud.documentai.v1beta3"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; - -// 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; - - // 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/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto deleted file mode 100644 index 61cd14a26..000000000 --- a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/documentai/v1beta3/document_io.proto"; -import "google/protobuf/timestamp.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProcessor"; -option java_package = "com.google.cloud.documentai.v1beta3"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; - -// The first-class citizen for DocumentAI. 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. - 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. - CREATING = 5; - - // The processor failed during creation. - 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. - 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; - - // 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/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto b/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto deleted file mode 100644 index 4bd4c16ab..000000000 --- a/owl-bot-staging/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -import "google/api/resource.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1beta3;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProcessorType"; -option java_package = "com.google.cloud.documentai.v1beta3"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; - -// 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. - string location_id = 1; - } - - // The resource name of the processor type. - string name = 1; - - // The type of the processor. - string type = 2; - - // The processor category. - string category = 3; - - // The locations in which this processor is available. - repeated LocationInfo available_locations = 4; - - // Whether the processor type allows creation. If yes, user can create a - // processor of this processor type. Otherwise, user needs to require for - // whitelisting. - bool allow_creation = 6; -} diff --git a/owl-bot-staging/v1beta3/src/index.ts b/owl-bot-staging/v1beta3/src/index.ts deleted file mode 100644 index 8bbd12507..000000000 --- a/owl-bot-staging/v1beta3/src/index.ts +++ /dev/null @@ -1,25 +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. -// -// ** 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 v1beta3 from './v1beta3'; -const DocumentProcessorServiceClient = v1beta3.DocumentProcessorServiceClient; -type DocumentProcessorServiceClient = v1beta3.DocumentProcessorServiceClient; -export {v1beta3, DocumentProcessorServiceClient}; -export default {v1beta3, DocumentProcessorServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client.ts b/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client.ts deleted file mode 100644 index b5fe1a5ed..000000000 --- a/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client.ts +++ /dev/null @@ -1,1502 +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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1beta3/document_processor_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './document_processor_service_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * 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. - * @class - * @memberof v1beta3 - */ -export class DocumentProcessorServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - documentProcessorServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DocumentProcessorServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DocumentProcessorServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set 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 = { - humanReviewConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - processorPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/processors/{processor}' - ), - processorTypePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/processorTypes/{processor_type}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listProcessors: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processors') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - - this.operationsClient = this._gaxModule.lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }).operationsClient(opts); - const batchProcessDocumentsResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.BatchProcessResponse') as gax.protobuf.Type; - const batchProcessDocumentsMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.BatchProcessMetadata') as gax.protobuf.Type; - const deleteProcessorResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteProcessorMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.DeleteProcessorMetadata') as gax.protobuf.Type; - const enableProcessorResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.EnableProcessorResponse') as gax.protobuf.Type; - const enableProcessorMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.EnableProcessorMetadata') as gax.protobuf.Type; - const disableProcessorResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.DisableProcessorResponse') as gax.protobuf.Type; - const disableProcessorMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.DisableProcessorMetadata') as gax.protobuf.Type; - const reviewDocumentResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.ReviewDocumentResponse') as gax.protobuf.Type; - const reviewDocumentMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - batchProcessDocumentsResponse.decode.bind(batchProcessDocumentsResponse), - batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata)), - deleteProcessor: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteProcessorResponse.decode.bind(deleteProcessorResponse), - deleteProcessorMetadata.decode.bind(deleteProcessorMetadata)), - enableProcessor: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - enableProcessorResponse.decode.bind(enableProcessorResponse), - enableProcessorMetadata.decode.bind(enableProcessorMetadata)), - disableProcessor: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - disableProcessorResponse.decode.bind(disableProcessorResponse), - disableProcessorMetadata.decode.bind(disableProcessorMetadata)), - reviewDocument: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - reviewDocumentResponse.decode.bind(reviewDocumentResponse), - reviewDocumentMetadata.decode.bind(reviewDocumentMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.documentai.v1beta3.DocumentProcessorService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.documentProcessorServiceStub) { - return this.documentProcessorServiceStub; - } - - // Put together the "service stub" for - // google.cloud.documentai.v1beta3.DocumentProcessorService. - this.documentProcessorServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.documentai.v1beta3.DocumentProcessorService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.documentai.v1beta3.DocumentProcessorService, - 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 documentProcessorServiceStubMethods = - ['processDocument', 'batchProcessDocuments', 'fetchProcessorTypes', 'listProcessors', 'createProcessor', 'deleteProcessor', 'enableProcessor', 'disableProcessor', 'reviewDocument']; - for (const methodName of documentProcessorServiceStubMethods) { - const callPromise = this.documentProcessorServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.documentProcessorServiceStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'documentai.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 'documentai.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 -- - // ------------------- - processDocument( - request?: protos.google.cloud.documentai.v1beta3.IProcessRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessResponse, - protos.google.cloud.documentai.v1beta3.IProcessRequest|undefined, {}|undefined - ]>; - processDocument( - request: protos.google.cloud.documentai.v1beta3.IProcessRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IProcessResponse, - protos.google.cloud.documentai.v1beta3.IProcessRequest|null|undefined, - {}|null|undefined>): void; - processDocument( - request: protos.google.cloud.documentai.v1beta3.IProcessRequest, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IProcessResponse, - protos.google.cloud.documentai.v1beta3.IProcessRequest|null|undefined, - {}|null|undefined>): void; -/** - * Processes a single document. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.documentai.v1beta3.Document} request.inlineDocument - * An inline document proto. - * @param {google.cloud.documentai.v1beta3.RawDocument} request.rawDocument - * A raw document content (bytes). - * @param {string} request.name - * Required. The processor resource name. - * @param {google.cloud.documentai.v1beta3.Document} request.document - * The document payload, the [content] and [mime_type] fields must be set. - * @param {boolean} request.skipHumanReview - * Whether Human Review feature should be skipped for this request. Default to - * false. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProcessResponse]{@link google.cloud.documentai.v1beta3.ProcessResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.processDocument(request); - */ - processDocument( - request?: protos.google.cloud.documentai.v1beta3.IProcessRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1beta3.IProcessResponse, - protos.google.cloud.documentai.v1beta3.IProcessRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1beta3.IProcessResponse, - protos.google.cloud.documentai.v1beta3.IProcessRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessResponse, - protos.google.cloud.documentai.v1beta3.IProcessRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.processDocument(request, options, callback); - } - fetchProcessorTypes( - request?: protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|undefined, {}|undefined - ]>; - fetchProcessorTypes( - request: protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|null|undefined, - {}|null|undefined>): void; - fetchProcessorTypes( - request: protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|null|undefined, - {}|null|undefined>): void; -/** - * Fetches processor types. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project of processor type to list. - * Format: projects/{project}/locations/{location} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [FetchProcessorTypesResponse]{@link google.cloud.documentai.v1beta3.FetchProcessorTypesResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.fetchProcessorTypes(request); - */ - fetchProcessorTypes( - request?: protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.fetchProcessorTypes(request, options, callback); - } - createProcessor( - request?: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|undefined, {}|undefined - ]>; - createProcessor( - request: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|null|undefined, - {}|null|undefined>): void; - createProcessor( - request: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|null|undefined, - {}|null|undefined>): void; -/** - * Creates a processor from the type processor that the user chose. - * The processor will be at "ENABLED" state by default after its creation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) under which to create the processor. - * Format: projects/{project}/locations/{location} - * @param {google.cloud.documentai.v1beta3.Processor} request.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. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Processor]{@link google.cloud.documentai.v1beta3.Processor}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * const [response] = await client.createProcessor(request); - */ - createProcessor( - request?: protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.ICreateProcessorRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createProcessor(request, options, callback); - } - - batchProcessDocuments( - request?: protos.google.cloud.documentai.v1beta3.IBatchProcessRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - batchProcessDocuments( - request: protos.google.cloud.documentai.v1beta3.IBatchProcessRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - batchProcessDocuments( - request: protos.google.cloud.documentai.v1beta3.IBatchProcessRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * LRO endpoint to batch process many documents. The output is written - * to Cloud Storage as JSON in the [Document] format. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor resource name. - * @param {number[]} request.inputConfigs - * The input config for each single document in the batch process. - * @param {google.cloud.documentai.v1beta3.BatchProcessRequest.BatchOutputConfig} request.outputConfig - * The overall output config for batch process. - * @param {google.cloud.documentai.v1beta3.BatchDocumentsInputConfig} request.inputDocuments - * The input documents for batch process. - * @param {google.cloud.documentai.v1beta3.DocumentOutputConfig} request.documentOutputConfig - * The overall output config for batch process. - * @param {boolean} request.skipHumanReview - * Whether Human Review feature should be skipped for this request. Default to - * false. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.batchProcessDocuments(request); - * const [response] = await operation.promise(); - */ - batchProcessDocuments( - request?: protos.google.cloud.documentai.v1beta3.IBatchProcessRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.batchProcessDocuments(request, options, callback); - } -/** - * Check the status of the long running operation returned by `batchProcessDocuments()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkBatchProcessDocumentsProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkBatchProcessDocumentsProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - deleteProcessor( - request?: protos.google.cloud.documentai.v1beta3.IDeleteProcessorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteProcessor( - request: protos.google.cloud.documentai.v1beta3.IDeleteProcessorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProcessor( - request: protos.google.cloud.documentai.v1beta3.IDeleteProcessorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Deletes the processor, unloads all deployed model artifacts if it was - * enabled and then deletes all artifacts associated with this processor. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor resource name to be deleted. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.deleteProcessor(request); - * const [response] = await operation.promise(); - */ - deleteProcessor( - request?: protos.google.cloud.documentai.v1beta3.IDeleteProcessorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProcessor(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteProcessor()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkDeleteProcessorProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkDeleteProcessorProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.deleteProcessor, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - enableProcessor( - request?: protos.google.cloud.documentai.v1beta3.IEnableProcessorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - enableProcessor( - request: protos.google.cloud.documentai.v1beta3.IEnableProcessorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - enableProcessor( - request: protos.google.cloud.documentai.v1beta3.IEnableProcessorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Enables a processor - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor resource name to be enabled. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.enableProcessor(request); - * const [response] = await operation.promise(); - */ - enableProcessor( - request?: protos.google.cloud.documentai.v1beta3.IEnableProcessorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.enableProcessor(request, options, callback); - } -/** - * Check the status of the long running operation returned by `enableProcessor()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkEnableProcessorProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkEnableProcessorProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.enableProcessor, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - disableProcessor( - request?: protos.google.cloud.documentai.v1beta3.IDisableProcessorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - disableProcessor( - request: protos.google.cloud.documentai.v1beta3.IDisableProcessorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - disableProcessor( - request: protos.google.cloud.documentai.v1beta3.IDisableProcessorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Disables a processor - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor resource name to be disabled. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.disableProcessor(request); - * const [response] = await operation.promise(); - */ - disableProcessor( - request?: protos.google.cloud.documentai.v1beta3.IDisableProcessorRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.disableProcessor(request, options, callback); - } -/** - * Check the status of the long running operation returned by `disableProcessor()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkDisableProcessorProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkDisableProcessorProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.disableProcessor, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - reviewDocument( - request?: protos.google.cloud.documentai.v1beta3.IReviewDocumentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - reviewDocument( - request: protos.google.cloud.documentai.v1beta3.IReviewDocumentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - reviewDocument( - request: protos.google.cloud.documentai.v1beta3.IReviewDocumentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; -/** - * Send a document for Human Review. The input document should be processed by - * the specified processor. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.documentai.v1beta3.Document} request.inlineDocument - * An inline document proto. - * @param {string} request.humanReviewConfig - * Required. The resource name of the HumanReviewConfig that the document will be - * reviewed with. - * @param {google.cloud.documentai.v1beta3.Document} request.document - * The document that needs human review. - * @param {boolean} request.enableSchemaValidation - * Whether the validation should be performed on the ad-hoc review request. - * @param {google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority} request.priority - * The priority of the human review task. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const [operation] = await client.reviewDocument(request); - * const [response] = await operation.promise(); - */ - reviewDocument( - request?: protos.google.cloud.documentai.v1beta3.IReviewDocumentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'human_review_config': request.humanReviewConfig || '', - }); - this.initialize(); - return this.innerApiCalls.reviewDocument(request, options, callback); - } -/** - * Check the status of the long running operation returned by `reviewDocument()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example - * const decodedOperation = await checkReviewDocumentProgress(name); - * console.log(decodedOperation.result); - * console.log(decodedOperation.done); - * console.log(decodedOperation.metadata); - */ - async checkReviewDocumentProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.reviewDocument, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - listProcessors( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessor[], - protos.google.cloud.documentai.v1beta3.IListProcessorsRequest|null, - protos.google.cloud.documentai.v1beta3.IListProcessorsResponse - ]>; - listProcessors( - request: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessor>): void; - listProcessors( - request: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, - callback: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessor>): void; -/** - * Lists all processors which belong to this project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) which owns this collection of Processors. - * Format: projects/{project}/locations/{location} - * @param {number} request.pageSize - * 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. - * @param {string} request.pageToken - * We will return the processors sorted by creation time. The page token - * will point to the next processor. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [Processor]{@link google.cloud.documentai.v1beta3.Processor}. - * 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 `listProcessorsAsync()` - * 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. - */ - listProcessors( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessor>, - callback?: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessor>): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessor[], - protos.google.cloud.documentai.v1beta3.IListProcessorsRequest|null, - protos.google.cloud.documentai.v1beta3.IListProcessorsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listProcessors(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 (project and location) which owns this collection of Processors. - * Format: projects/{project}/locations/{location} - * @param {number} request.pageSize - * 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. - * @param {string} request.pageToken - * We will return the processors sorted by creation time. The page token - * will point to the next processor. - * @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 [Processor]{@link google.cloud.documentai.v1beta3.Processor} 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 `listProcessorsAsync()` - * 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. - */ - listProcessorsStream( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listProcessors.createStream( - this.innerApiCalls.listProcessors as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProcessors`, 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 (project and location) which owns this collection of Processors. - * Format: projects/{project}/locations/{location} - * @param {number} request.pageSize - * 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. - * @param {string} request.pageToken - * We will return the processors sorted by creation time. The page token - * will point to the next processor. - * @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 - * [Processor]{@link google.cloud.documentai.v1beta3.Processor}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * const iterable = client.listProcessorsAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - listProcessorsAsync( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listProcessors.asyncIterate( - this.innerApiCalls['listProcessors'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified humanReviewConfig resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} processor - * @returns {string} Resource name string. - */ - humanReviewConfigPath(project:string,location:string,processor:string) { - return this.pathTemplates.humanReviewConfigPathTemplate.render({ - project: project, - location: location, - processor: processor, - }); - } - - /** - * Parse the project from HumanReviewConfig resource. - * - * @param {string} humanReviewConfigName - * A fully-qualified path representing HumanReviewConfig resource. - * @returns {string} A string representing the project. - */ - matchProjectFromHumanReviewConfigName(humanReviewConfigName: string) { - return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).project; - } - - /** - * Parse the location from HumanReviewConfig resource. - * - * @param {string} humanReviewConfigName - * A fully-qualified path representing HumanReviewConfig resource. - * @returns {string} A string representing the location. - */ - matchLocationFromHumanReviewConfigName(humanReviewConfigName: string) { - return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).location; - } - - /** - * Parse the processor from HumanReviewConfig resource. - * - * @param {string} humanReviewConfigName - * A fully-qualified path representing HumanReviewConfig resource. - * @returns {string} A string representing the processor. - */ - matchProcessorFromHumanReviewConfigName(humanReviewConfigName: string) { - return this.pathTemplates.humanReviewConfigPathTemplate.match(humanReviewConfigName).processor; - } - - /** - * 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 processor resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} processor - * @returns {string} Resource name string. - */ - processorPath(project:string,location:string,processor:string) { - return this.pathTemplates.processorPathTemplate.render({ - project: project, - location: location, - processor: processor, - }); - } - - /** - * Parse the project from Processor resource. - * - * @param {string} processorName - * A fully-qualified path representing Processor resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProcessorName(processorName: string) { - return this.pathTemplates.processorPathTemplate.match(processorName).project; - } - - /** - * Parse the location from Processor resource. - * - * @param {string} processorName - * A fully-qualified path representing Processor resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProcessorName(processorName: string) { - return this.pathTemplates.processorPathTemplate.match(processorName).location; - } - - /** - * Parse the processor from Processor resource. - * - * @param {string} processorName - * A fully-qualified path representing Processor resource. - * @returns {string} A string representing the processor. - */ - matchProcessorFromProcessorName(processorName: string) { - return this.pathTemplates.processorPathTemplate.match(processorName).processor; - } - - /** - * Return a fully-qualified processorType resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} processor_type - * @returns {string} Resource name string. - */ - processorTypePath(project:string,location:string,processorType:string) { - return this.pathTemplates.processorTypePathTemplate.render({ - project: project, - location: location, - processor_type: processorType, - }); - } - - /** - * Parse the project from ProcessorType resource. - * - * @param {string} processorTypeName - * A fully-qualified path representing ProcessorType resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProcessorTypeName(processorTypeName: string) { - return this.pathTemplates.processorTypePathTemplate.match(processorTypeName).project; - } - - /** - * Parse the location from ProcessorType resource. - * - * @param {string} processorTypeName - * A fully-qualified path representing ProcessorType resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProcessorTypeName(processorTypeName: string) { - return this.pathTemplates.processorTypePathTemplate.match(processorTypeName).location; - } - - /** - * Parse the processor_type from ProcessorType resource. - * - * @param {string} processorTypeName - * A fully-qualified path representing ProcessorType resource. - * @returns {string} A string representing the processor_type. - */ - matchProcessorTypeFromProcessorTypeName(processorTypeName: string) { - return this.pathTemplates.processorTypePathTemplate.match(processorTypeName).processor_type; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - this.initialize(); - if (!this._terminated) { - return this.documentProcessorServiceStub!.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client_config.json b/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client_config.json deleted file mode 100644 index 8fde58b8d..000000000 --- a/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_client_config.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "interfaces": { - "google.cloud.documentai.v1beta3.DocumentProcessorService": { - "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": { - "ProcessDocument": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "BatchProcessDocuments": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "FetchProcessorTypes": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProcessors": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateProcessor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProcessor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "EnableProcessor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DisableProcessor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ReviewDocument": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_proto_list.json b/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_proto_list.json deleted file mode 100644 index e6cd85900..000000000 --- a/owl-bot-staging/v1beta3/src/v1beta3/document_processor_service_proto_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "../../protos/google/cloud/documentai/v1beta3/document.proto", - "../../protos/google/cloud/documentai/v1beta3/document_io.proto", - "../../protos/google/cloud/documentai/v1beta3/document_processor_service.proto", - "../../protos/google/cloud/documentai/v1beta3/geometry.proto", - "../../protos/google/cloud/documentai/v1beta3/operation_metadata.proto", - "../../protos/google/cloud/documentai/v1beta3/processor.proto", - "../../protos/google/cloud/documentai/v1beta3/processor_type.proto" -] diff --git a/owl-bot-staging/v1beta3/src/v1beta3/gapic_metadata.json b/owl-bot-staging/v1beta3/src/v1beta3/gapic_metadata.json deleted file mode 100644 index 791a44e4d..000000000 --- a/owl-bot-staging/v1beta3/src/v1beta3/gapic_metadata.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.documentai.v1beta3", - "libraryPackage": "@google-cloud/documentai", - "services": { - "DocumentProcessorService": { - "clients": { - "grpc": { - "libraryClient": "DocumentProcessorServiceClient", - "rpcs": { - "ProcessDocument": { - "methods": [ - "processDocument" - ] - }, - "FetchProcessorTypes": { - "methods": [ - "fetchProcessorTypes" - ] - }, - "CreateProcessor": { - "methods": [ - "createProcessor" - ] - }, - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - }, - "DeleteProcessor": { - "methods": [ - "deleteProcessor" - ] - }, - "EnableProcessor": { - "methods": [ - "enableProcessor" - ] - }, - "DisableProcessor": { - "methods": [ - "disableProcessor" - ] - }, - "ReviewDocument": { - "methods": [ - "reviewDocument" - ] - }, - "ListProcessors": { - "methods": [ - "listProcessors", - "listProcessorsStream", - "listProcessorsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentProcessorServiceClient", - "rpcs": { - "ProcessDocument": { - "methods": [ - "processDocument" - ] - }, - "FetchProcessorTypes": { - "methods": [ - "fetchProcessorTypes" - ] - }, - "CreateProcessor": { - "methods": [ - "createProcessor" - ] - }, - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - }, - "DeleteProcessor": { - "methods": [ - "deleteProcessor" - ] - }, - "EnableProcessor": { - "methods": [ - "enableProcessor" - ] - }, - "DisableProcessor": { - "methods": [ - "disableProcessor" - ] - }, - "ReviewDocument": { - "methods": [ - "reviewDocument" - ] - }, - "ListProcessors": { - "methods": [ - "listProcessors", - "listProcessorsStream", - "listProcessorsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1beta3/src/v1beta3/index.ts b/owl-bot-staging/v1beta3/src/v1beta3/index.ts deleted file mode 100644 index 2f6c91a42..000000000 --- a/owl-bot-staging/v1beta3/src/v1beta3/index.ts +++ /dev/null @@ -1,19 +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. -// -// ** 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 {DocumentProcessorServiceClient} from './document_processor_service_client'; diff --git a/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 7a0b0174d..000000000 --- a/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +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. -// -// ** 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 documentai = require('@google-cloud/documentai'); - -function main() { - const documentProcessorServiceClient = new documentai.DocumentProcessorServiceClient(); -} - -main(); diff --git a/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 2bccab99e..000000000 --- a/owl-bot-staging/v1beta3/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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. -// -// ** 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 {DocumentProcessorServiceClient} from '@google-cloud/documentai'; - -// check that the client class type name can be used -function doStuffWithDocumentProcessorServiceClient(client: DocumentProcessorServiceClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const documentProcessorServiceClient = new DocumentProcessorServiceClient(); - doStuffWithDocumentProcessorServiceClient(documentProcessorServiceClient); -} - -main(); diff --git a/owl-bot-staging/v1beta3/system-test/install.ts b/owl-bot-staging/v1beta3/system-test/install.ts deleted file mode 100644 index 1f850b522..000000000 --- a/owl-bot-staging/v1beta3/system-test/install.ts +++ /dev/null @@ -1,49 +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. -// -// ** 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/v1beta3/test/gapic_document_processor_service_v1beta3.ts b/owl-bot-staging/v1beta3/test/gapic_document_processor_service_v1beta3.ts deleted file mode 100644 index fa9f9b3ae..000000000 --- a/owl-bot-staging/v1beta3/test/gapic_document_processor_service_v1beta3.ts +++ /dev/null @@ -1,1587 +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. -// -// ** 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 documentprocessorserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta3.DocumentProcessorServiceClient', () => { - it('has servicePath', () => { - const servicePath = documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentProcessorServiceStub, undefined); - await client.initialize(); - assert(client.documentProcessorServiceStub); - }); - - it('has close method', () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - 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 documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - 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('processDocument', () => { - it('invokes processDocument without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessResponse()); - client.innerApiCalls.processDocument = stubSimpleCall(expectedResponse); - const [response] = await client.processDocument(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.processDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes processDocument without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessResponse()); - client.innerApiCalls.processDocument = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.processDocument( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.processDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes processDocument with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.processDocument(request), expectedError); - assert((client.innerApiCalls.processDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('fetchProcessorTypes', () => { - it('invokes fetchProcessorTypes without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.FetchProcessorTypesResponse()); - client.innerApiCalls.fetchProcessorTypes = stubSimpleCall(expectedResponse); - const [response] = await client.fetchProcessorTypes(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes fetchProcessorTypes without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.FetchProcessorTypesResponse()); - client.innerApiCalls.fetchProcessorTypes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.fetchProcessorTypes( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IFetchProcessorTypesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes fetchProcessorTypes with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.fetchProcessorTypes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchProcessorTypes(request), expectedError); - assert((client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('createProcessor', () => { - it('invokes createProcessor without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.CreateProcessorRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()); - client.innerApiCalls.createProcessor = stubSimpleCall(expectedResponse); - const [response] = await client.createProcessor(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProcessor without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.CreateProcessorRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()); - client.innerApiCalls.createProcessor = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProcessor( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessor|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProcessor with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.CreateProcessorRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createProcessor = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProcessor(request), expectedError); - assert((client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - - describe('batchProcessDocuments', () => { - it('invokes batchProcessDocuments without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.BatchProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchProcessDocuments(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchProcessDocuments without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.BatchProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchProcessDocuments( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes batchProcessDocuments with call error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.BatchProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchProcessDocuments(request), expectedError); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes batchProcessDocuments with LRO error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.BatchProcessRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchProcessDocuments(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkBatchProcessDocumentsProgress without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchProcessDocumentsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkBatchProcessDocumentsProgress with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchProcessDocumentsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteProcessor', () => { - it('invokes deleteProcessor without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DeleteProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteProcessor = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteProcessor(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProcessor without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DeleteProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteProcessor = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProcessor( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProcessor with call error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DeleteProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteProcessor(request), expectedError); - assert((client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProcessor with LRO error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DeleteProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteProcessor(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteProcessorProgress without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteProcessorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteProcessorProgress with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteProcessorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('enableProcessor', () => { - it('invokes enableProcessor without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.EnableProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.enableProcessor = stubLongRunningCall(expectedResponse); - const [operation] = await client.enableProcessor(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes enableProcessor without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.EnableProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.enableProcessor = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.enableProcessor( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes enableProcessor with call error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.EnableProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.enableProcessor(request), expectedError); - assert((client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes enableProcessor with LRO error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.EnableProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.enableProcessor(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkEnableProcessorProgress without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkEnableProcessorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkEnableProcessorProgress with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkEnableProcessorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('disableProcessor', () => { - it('invokes disableProcessor without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DisableProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.disableProcessor = stubLongRunningCall(expectedResponse); - const [operation] = await client.disableProcessor(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes disableProcessor without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DisableProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.disableProcessor = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.disableProcessor( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes disableProcessor with call error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DisableProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.disableProcessor(request), expectedError); - assert((client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes disableProcessor with LRO error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.DisableProcessorRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.disableProcessor(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDisableProcessorProgress without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDisableProcessorProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDisableProcessorProgress with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDisableProcessorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('reviewDocument', () => { - it('invokes reviewDocument without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ReviewDocumentRequest()); - request.humanReviewConfig = ''; - const expectedHeaderRequestParams = "human_review_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.reviewDocument = stubLongRunningCall(expectedResponse); - const [operation] = await client.reviewDocument(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes reviewDocument without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ReviewDocumentRequest()); - request.humanReviewConfig = ''; - const expectedHeaderRequestParams = "human_review_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.reviewDocument = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reviewDocument( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes reviewDocument with call error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ReviewDocumentRequest()); - request.humanReviewConfig = ''; - const expectedHeaderRequestParams = "human_review_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reviewDocument(request), expectedError); - assert((client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes reviewDocument with LRO error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ReviewDocumentRequest()); - request.humanReviewConfig = ''; - const expectedHeaderRequestParams = "human_review_config="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reviewDocument(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkReviewDocumentProgress without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkReviewDocumentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkReviewDocumentProgress with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReviewDocumentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProcessors', () => { - it('invokes listProcessors without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - ]; - client.innerApiCalls.listProcessors = stubSimpleCall(expectedResponse); - const [response] = await client.listProcessors(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProcessors without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - ]; - client.innerApiCalls.listProcessors = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProcessors( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessor[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProcessors with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listProcessors = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProcessors(request), expectedError); - assert((client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProcessorsStream without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - ]; - client.descriptors.page.listProcessors.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProcessorsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.Processor[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1beta3.Processor) => { - 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.listProcessors.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProcessors, request)); - assert.strictEqual( - (client.descriptors.page.listProcessors.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listProcessorsStream with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listProcessors.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProcessorsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.Processor[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1beta3.Processor) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProcessors.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProcessors, request)); - assert.strictEqual( - (client.descriptors.page.listProcessors.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProcessors without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Processor()), - ]; - client.descriptors.page.listProcessors.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.documentai.v1beta3.IProcessor[] = []; - const iterable = client.listProcessorsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProcessors.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProcessors.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listProcessors with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listProcessors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProcessorsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.documentai.v1beta3.IProcessor[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProcessors.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listProcessors.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('humanReviewConfig', () => { - const fakePath = "/rendered/path/humanReviewConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - processor: "processorValue", - }; - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.humanReviewConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.humanReviewConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('humanReviewConfigPath', () => { - const result = client.humanReviewConfigPath("projectValue", "locationValue", "processorValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.humanReviewConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHumanReviewConfigName', () => { - const result = client.matchProjectFromHumanReviewConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromHumanReviewConfigName', () => { - const result = client.matchLocationFromHumanReviewConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorFromHumanReviewConfigName', () => { - const result = client.matchProcessorFromHumanReviewConfigName(fakePath); - assert.strictEqual(result, "processorValue"); - assert((client.pathTemplates.humanReviewConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - 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('processor', () => { - const fakePath = "/rendered/path/processor"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - processor: "processorValue", - }; - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.processorPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.processorPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('processorPath', () => { - const result = client.processorPath("projectValue", "locationValue", "processorValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.processorPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProcessorName', () => { - const result = client.matchProjectFromProcessorName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.processorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProcessorName', () => { - const result = client.matchLocationFromProcessorName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.processorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorFromProcessorName', () => { - const result = client.matchProcessorFromProcessorName(fakePath); - assert.strictEqual(result, "processorValue"); - assert((client.pathTemplates.processorPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('processorType', () => { - const fakePath = "/rendered/path/processorType"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - processor_type: "processorTypeValue", - }; - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.processorTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.processorTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('processorTypePath', () => { - const result = client.processorTypePath("projectValue", "locationValue", "processorTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.processorTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProcessorTypeName', () => { - const result = client.matchProjectFromProcessorTypeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.processorTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProcessorTypeName', () => { - const result = client.matchLocationFromProcessorTypeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.processorTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorTypeFromProcessorTypeName', () => { - const result = client.matchProcessorTypeFromProcessorTypeName(fakePath); - assert.strictEqual(result, "processorTypeValue"); - assert((client.pathTemplates.processorTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1beta3/tsconfig.json b/owl-bot-staging/v1beta3/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/v1beta3/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/v1beta3/webpack.config.js b/owl-bot-staging/v1beta3/webpack.config.js deleted file mode 100644 index fc7bef574..000000000 --- a/owl-bot-staging/v1beta3/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: 'DocumentProcessorService', - filename: './document-processor-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/protos/google/cloud/documentai/v1beta2/document_understanding.proto b/protos/google/cloud/documentai/v1beta2/document_understanding.proto index cf336f014..137ba5e31 100644 --- a/protos/google/cloud/documentai/v1beta2/document_understanding.proto +++ b/protos/google/cloud/documentai/v1beta2/document_understanding.proto @@ -36,7 +36,7 @@ option ruby_package = "Google::Cloud::DocumentAI::V1beta2"; // documents using state-of-the-art Google AI such as natural language, // computer vision, and translation. service DocumentUnderstandingService { - option (google.api.default_host) = "us-documentai.googleapis.com"; + option (google.api.default_host) = "documentai.googleapis.com"; option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; // LRO endpoint to batch process many documents. The output is written diff --git a/protos/protos.json b/protos/protos.json index b7abceda7..04a286de0 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -2802,7 +2802,7 @@ }, "DocumentUnderstandingService": { "options": { - "(google.api.default_host)": "us-documentai.googleapis.com", + "(google.api.default_host)": "documentai.googleapis.com", "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" }, "methods": { diff --git a/src/v1/document_processor_service_client.ts b/src/v1/document_processor_service_client.ts index 32e602d35..faec6ef8a 100644 --- a/src/v1/document_processor_service_client.ts +++ b/src/v1/document_processor_service_client.ts @@ -133,6 +133,8 @@ export class DocumentProcessorServiceClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { diff --git a/src/v1beta1/document_understanding_service_client.ts b/src/v1beta1/document_understanding_service_client.ts index 8a006d5e8..e0db5be5b 100644 --- a/src/v1beta1/document_understanding_service_client.ts +++ b/src/v1beta1/document_understanding_service_client.ts @@ -131,6 +131,8 @@ export class DocumentUnderstandingServiceClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { diff --git a/src/v1beta2/document_understanding_service_client.ts b/src/v1beta2/document_understanding_service_client.ts index ca4fb252d..6466e5015 100644 --- a/src/v1beta2/document_understanding_service_client.ts +++ b/src/v1beta2/document_understanding_service_client.ts @@ -131,6 +131,8 @@ export class DocumentUnderstandingServiceClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { @@ -265,7 +267,7 @@ export class DocumentUnderstandingServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - return 'us-documentai.googleapis.com'; + return 'documentai.googleapis.com'; } /** @@ -274,7 +276,7 @@ export class DocumentUnderstandingServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - return 'us-documentai.googleapis.com'; + return 'documentai.googleapis.com'; } /** diff --git a/src/v1beta3/document_processor_service_client.ts b/src/v1beta3/document_processor_service_client.ts index 44cb40c5e..3e3498d86 100644 --- a/src/v1beta3/document_processor_service_client.ts +++ b/src/v1beta3/document_processor_service_client.ts @@ -137,6 +137,8 @@ export class DocumentProcessorServiceClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { From 0a9b3ad537506e49163309a6851999e442bee5e4 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 11 Aug 2021 22:50:59 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= 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 --- src/v1/document_processor_service_client.ts | 2 -- src/v1beta1/document_understanding_service_client.ts | 2 -- src/v1beta2/document_understanding_service_client.ts | 2 -- src/v1beta3/document_processor_service_client.ts | 2 -- 4 files changed, 8 deletions(-) diff --git a/src/v1/document_processor_service_client.ts b/src/v1/document_processor_service_client.ts index faec6ef8a..32e602d35 100644 --- a/src/v1/document_processor_service_client.ts +++ b/src/v1/document_processor_service_client.ts @@ -133,8 +133,6 @@ export class DocumentProcessorServiceClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; - - // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { diff --git a/src/v1beta1/document_understanding_service_client.ts b/src/v1beta1/document_understanding_service_client.ts index e0db5be5b..8a006d5e8 100644 --- a/src/v1beta1/document_understanding_service_client.ts +++ b/src/v1beta1/document_understanding_service_client.ts @@ -131,8 +131,6 @@ export class DocumentUnderstandingServiceClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; - - // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { diff --git a/src/v1beta2/document_understanding_service_client.ts b/src/v1beta2/document_understanding_service_client.ts index 6466e5015..62ce5d4ca 100644 --- a/src/v1beta2/document_understanding_service_client.ts +++ b/src/v1beta2/document_understanding_service_client.ts @@ -131,8 +131,6 @@ export class DocumentUnderstandingServiceClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; - - // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { diff --git a/src/v1beta3/document_processor_service_client.ts b/src/v1beta3/document_processor_service_client.ts index 3e3498d86..44cb40c5e 100644 --- a/src/v1beta3/document_processor_service_client.ts +++ b/src/v1beta3/document_processor_service_client.ts @@ -137,8 +137,6 @@ export class DocumentProcessorServiceClient { // Save the auth object to the client, for use by other methods. this.auth = this._gaxGrpc.auth as gax.GoogleAuth; - - // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) {