From b611e7a0f0d93f32f0e52141825814ed299f4199 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 14 Nov 2022 21:17:23 +0000 Subject: [PATCH 1/4] feat: added TrainProcessorVersion, EvaluateProcessorVersion, GetEvaluation, and ListEvaluations v1beta3 APIs feat: added evaluation.proto feat: added document_schema field in ProcessorVersion processor.proto feat: added image_quality_scores field in Document.Page in document.proto feat: added font_family field in Document.Style in document.proto PiperOrigin-RevId: 488417413 Source-Link: https://github.com/googleapis/googleapis/commit/6b780a3cb3c35caad44174ed388cc105062c0a0f Source-Link: https://github.com/googleapis/googleapis-gen/commit/99c8d66a1f727ae3cb6697832690dbaaa318cd85 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRvY3VtZW50YWkvLk93bEJvdC55YW1sIiwiaCI6Ijk5YzhkNjZhMWY3MjdhZTNjYjY2OTc4MzI2OTBkYmFhYTMxOGNkODUifQ== --- .../google-cloud-documentai/v1/.eslintignore | 7 + .../google-cloud-documentai/v1/.eslintrc.json | 3 + .../google-cloud-documentai/v1/.gitignore | 14 + .../google-cloud-documentai/v1/.jsdoc.js | 55 + .../google-cloud-documentai/v1/.mocharc.js | 33 + .../google-cloud-documentai/v1/.prettierrc.js | 22 + .../google-cloud-documentai/v1/README.md | 1 + .../v1/linkinator.config.json | 16 + .../google-cloud-documentai/v1/package.json | 64 + .../google/cloud/documentai/v1/barcode.proto | 69 + .../google/cloud/documentai/v1/document.proto | 820 ++++ .../cloud/documentai/v1/document_io.proto | 91 + .../v1/document_processor_service.proto | 801 +++ .../cloud/documentai/v1/document_schema.proto | 141 + .../google/cloud/documentai/v1/geometry.proto | 55 + .../documentai/v1/operation_metadata.proto | 66 + .../cloud/documentai/v1/processor.proto | 189 + .../cloud/documentai/v1/processor_type.proto | 63 + ...ocessor_service.batch_process_documents.js | 79 + ...ment_processor_service.create_processor.js | 68 + ...ment_processor_service.delete_processor.js | 62 + ...cessor_service.delete_processor_version.js | 62 + ...cessor_service.deploy_processor_version.js | 62 + ...ent_processor_service.disable_processor.js | 62 + ...ment_processor_service.enable_processor.js | 62 + ...processor_service.fetch_processor_types.js | 63 + ...ocument_processor_service.get_processor.js | 61 + ...processor_service.get_processor_version.js | 61 + ..._processor_service.list_processor_types.js | 75 + ...ocessor_service.list_processor_versions.js | 75 + ...ument_processor_service.list_processors.js | 75 + ...ment_processor_service.process_document.js | 85 + ...ument_processor_service.review_document.js | 79 + ...r_service.set_default_processor_version.js | 69 + ...ssor_service.undeploy_processor_version.js | 62 + ...t_metadata.google.cloud.documentai.v1.json | 771 +++ .../google-cloud-documentai/v1/src/index.ts | 25 + .../v1/document_processor_service_client.ts | 2760 +++++++++++ ...ument_processor_service_client_config.json | 97 + ...document_processor_service_proto_list.json | 11 + .../v1/src/v1/gapic_metadata.json | 205 + .../v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../v1/system-test/install.ts | 49 + .../gapic_document_processor_service_v1.ts | 3558 ++++++++++++++ .../google-cloud-documentai/v1/tsconfig.json | 19 + .../v1/webpack.config.js | 64 + .../v1beta1/.eslintignore | 7 + .../v1beta1/.eslintrc.json | 3 + .../v1beta1/.gitignore | 14 + .../google-cloud-documentai/v1beta1/.jsdoc.js | 55 + .../v1beta1/.mocharc.js | 33 + .../v1beta1/.prettierrc.js | 22 + .../google-cloud-documentai/v1beta1/README.md | 1 + .../v1beta1/linkinator.config.json | 16 + .../v1beta1/package.json | 64 + .../cloud/documentai/v1beta1/document.proto | 449 ++ .../v1beta1/document_understanding.proto | 302 ++ .../cloud/documentai/v1beta1/geometry.proto | 57 + ...tanding_service.batch_process_documents.js | 68 + ...adata.google.cloud.documentai.v1beta1.json | 59 + .../v1beta1/src/index.ts | 25 + .../document_understanding_service_client.ts | 431 ++ ...t_understanding_service_client_config.json | 31 + ...ment_understanding_service_proto_list.json | 5 + .../v1beta1/src/v1beta1/gapic_metadata.json | 33 + .../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 | 316 ++ .../v1beta1/tsconfig.json | 19 + .../v1beta1/webpack.config.js | 64 + .../v1beta2/.eslintignore | 7 + .../v1beta2/.eslintrc.json | 3 + .../v1beta2/.gitignore | 14 + .../google-cloud-documentai/v1beta2/.jsdoc.js | 55 + .../v1beta2/.mocharc.js | 33 + .../v1beta2/.prettierrc.js | 22 + .../google-cloud-documentai/v1beta2/README.md | 1 + .../v1beta2/linkinator.config.json | 16 + .../v1beta2/package.json | 64 + .../cloud/documentai/v1beta2/document.proto | 518 ++ .../v1beta2/document_understanding.proto | 346 ++ .../cloud/documentai/v1beta2/geometry.proto | 56 + ...tanding_service.batch_process_documents.js | 68 + ..._understanding_service.process_document.js | 104 + ...adata.google.cloud.documentai.v1beta2.json | 131 + .../v1beta2/src/index.ts | 25 + .../document_understanding_service_client.ts | 532 ++ ...t_understanding_service_client_config.json | 36 + ...ment_understanding_service_proto_list.json | 5 + .../v1beta2/src/v1beta2/gapic_metadata.json | 43 + .../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 | 428 ++ .../v1beta2/tsconfig.json | 19 + .../v1beta2/webpack.config.js | 64 + .../v1beta3/.eslintignore | 7 + .../v1beta3/.eslintrc.json | 3 + .../v1beta3/.gitignore | 14 + .../google-cloud-documentai/v1beta3/.jsdoc.js | 55 + .../v1beta3/.mocharc.js | 33 + .../v1beta3/.prettierrc.js | 22 + .../google-cloud-documentai/v1beta3/README.md | 1 + .../v1beta3/linkinator.config.json | 16 + .../v1beta3/package.json | 64 + .../cloud/documentai/v1beta3/barcode.proto | 69 + .../cloud/documentai/v1beta3/document.proto | 820 ++++ .../documentai/v1beta3/document_io.proto | 84 + .../v1beta3/document_processor_service.proto | 1070 ++++ .../documentai/v1beta3/document_schema.proto | 141 + .../cloud/documentai/v1beta3/evaluation.proto | 164 + .../cloud/documentai/v1beta3/geometry.proto | 55 + .../v1beta3/operation_metadata.proto | 66 + .../cloud/documentai/v1beta3/processor.proto | 189 + .../documentai/v1beta3/processor_type.proto | 63 + ...ocessor_service.batch_process_documents.js | 87 + ...ment_processor_service.create_processor.js | 68 + ...ment_processor_service.delete_processor.js | 62 + ...cessor_service.delete_processor_version.js | 62 + ...cessor_service.deploy_processor_version.js | 62 + ...ent_processor_service.disable_processor.js | 62 + ...ment_processor_service.enable_processor.js | 62 + ...ssor_service.evaluate_processor_version.js | 68 + ...processor_service.fetch_processor_types.js | 63 + ...cument_processor_service.get_evaluation.js | 62 + ...ocument_processor_service.get_processor.js | 61 + ...processor_service.get_processor_version.js | 61 + ...ment_processor_service.list_evaluations.js | 75 + ..._processor_service.list_processor_types.js | 75 + ...ocessor_service.list_processor_versions.js | 75 + ...ument_processor_service.list_processors.js | 75 + ...ment_processor_service.process_document.js | 89 + ...ument_processor_service.review_document.js | 83 + ...r_service.set_default_processor_version.js | 69 + ...ocessor_service.train_processor_version.js | 82 + ...ssor_service.undeploy_processor_version.js | 62 + ...adata.google.cloud.documentai.v1beta3.json | 975 ++++ .../v1beta3/src/index.ts | 25 + .../document_processor_service_client.ts | 3321 +++++++++++++ ...ument_processor_service_client_config.json | 113 + ...document_processor_service_proto_list.json | 12 + .../v1beta3/src/v1beta3/gapic_metadata.json | 249 + .../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 | 4281 +++++++++++++++++ .../v1beta3/tsconfig.json | 19 + .../v1beta3/webpack.config.js | 64 + 154 files changed, 29814 insertions(+) create mode 100644 owl-bot-staging/google-cloud-documentai/v1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-documentai/v1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1/.gitignore create mode 100644 owl-bot-staging/google-cloud-documentai/v1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/README.md create mode 100644 owl-bot-staging/google-cloud-documentai/v1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1/package.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/barcode.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_io.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_processor_service.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_schema.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/geometry.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/operation_metadata.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor_type.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.batch_process_documents.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.create_processor.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.deploy_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.disable_processor.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.enable_processor.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.fetch_processor_types.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_types.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_versions.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processors.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.process_document.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.review_document.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.set_default_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.undeploy_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/snippet_metadata.google.cloud.documentai.v1.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/v1/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1/test/gapic_document_processor_service_v1.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.eslintignore create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.gitignore create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/README.md create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/package.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/document_understanding_service.batch_process_documents.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.documentai.v1beta1.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/test/gapic_document_understanding_service_v1beta1.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.eslintignore create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.gitignore create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/README.md create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/package.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.batch_process_documents.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.process_document.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.documentai.v1beta2.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/test/gapic_document_understanding_service_v1beta2.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.eslintignore create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.gitignore create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/README.md create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/package.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/barcode.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_schema.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/evaluation.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.batch_process_documents.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.create_processor.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.deploy_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.disable_processor.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.enable_processor.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_evaluation.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_evaluations.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_types.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_versions.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processors.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.process_document.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.review_document.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.set_default_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.train_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/test/gapic_document_processor_service_v1beta3.ts create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/webpack.config.js diff --git a/owl-bot-staging/google-cloud-documentai/v1/.eslintignore b/owl-bot-staging/google-cloud-documentai/v1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-documentai/v1/.eslintrc.json b/owl-bot-staging/google-cloud-documentai/v1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/.gitignore b/owl-bot-staging/google-cloud-documentai/v1/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/google-cloud-documentai/v1/.jsdoc.js b/owl-bot-staging/google-cloud-documentai/v1/.jsdoc.js new file mode 100644 index 00000000000..75c76e52a54 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/documentai', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-documentai/v1/.mocharc.js b/owl-bot-staging/google-cloud-documentai/v1/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-documentai/v1/.prettierrc.js b/owl-bot-staging/google-cloud-documentai/v1/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/README.md b/owl-bot-staging/google-cloud-documentai/v1/README.md new file mode 100644 index 00000000000..f41eef852ae --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/README.md @@ -0,0 +1 @@ +Documentai: Nodejs Client diff --git a/owl-bot-staging/google-cloud-documentai/v1/linkinator.config.json b/owl-bot-staging/google-cloud-documentai/v1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/package.json b/owl-bot-staging/google-cloud-documentai/v1/package.json new file mode 100644 index 00000000000..41e8970a7ad --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/barcode.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/barcode.proto new file mode 100644 index 00000000000..bb841771ade --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/barcode.proto @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "BarcodeProto"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// Encodes the detailed information of a barcode. +message Barcode { + // Format of a barcode. + // The supported formats are: + // + // - `CODE_128`: Code 128 type. + // - `CODE_39`: Code 39 type. + // - `CODE_93`: Code 93 type. + // - `CODABAR`: Codabar type. + // - `DATA_MATRIX`: 2D Data Matrix type. + // - `ITF`: ITF type. + // - `EAN_13`: EAN-13 type. + // - `EAN_8`: EAN-8 type. + // - `QR_CODE`: 2D QR code type. + // - `UPC_A`: UPC-A type. + // - `UPC_E`: UPC-E type. + // - `PDF417`: PDF417 type. + // - `AZTEC`: 2D Aztec code type. + // - `DATABAR`: GS1 DataBar code type. + string format = 1; + + // Value format describes the format of the value that a barcode + // encodes. + // The supported formats are: + // + // - `CONTACT_INFO`: Contact information. + // - `EMAIL`: Email address. + // - `ISBN`: ISBN identifier. + // - `PHONE`: Phone number. + // - `PRODUCT`: Product. + // - `SMS`: SMS message. + // - `TEXT`: Text string. + // - `URL`: URL address. + // - `WIFI`: Wifi information. + // - `GEO`: Geo-localization. + // - `CALENDAR_EVENT`: Calendar event. + // - `DRIVER_LICENSE`: Driver's license. + string value_format = 2; + + // Raw value encoded in the barcode. + // For example: `'MEBKM:TITLE:Google;URL:https://www.google.com;;'`. + string raw_value = 3; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document.proto new file mode 100644 index 00000000000..c4fbb21ceca --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document.proto @@ -0,0 +1,820 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +import "google/api/field_behavior.proto"; +import "google/cloud/documentai/v1/barcode.proto"; +import "google/cloud/documentai/v1/geometry.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; +import "google/type/color.proto"; +import "google/type/date.proto"; +import "google/type/datetime.proto"; +import "google/type/money.proto"; +import "google/type/postal_address.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// Document represents the canonical document resource in Document AI. It is an +// interchange format that provides insights into documents and allows for +// collaboration between users and Document AI to iterate and optimize for +// quality. +message Document { + // For a large document, sharding may be performed to produce several + // document shards. Each document shard contains this field to detail which + // shard it is. + message ShardInfo { + // The 0-based index of this shard. + int64 shard_index = 1; + + // Total number of shards. + int64 shard_count = 2; + + // The index of the first character in [Document.text][google.cloud.documentai.v1.Document.text] in the overall + // document global text. + int64 text_offset = 3; + } + + // Annotation for common text style attributes. This adheres to CSS + // conventions as much as possible. + message Style { + // Font size with unit. + message FontSize { + // Font size for the text. + float size = 1; + + // Unit for the font size. Follows CSS naming (in, px, pt, etc.). + string unit = 2; + } + + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. + TextAnchor text_anchor = 1; + + // Text color. + google.type.Color color = 2; + + // Text background color. + google.type.Color background_color = 3; + + // Font weight. Possible values are normal, bold, bolder, and lighter. + // https://www.w3schools.com/cssref/pr_font_weight.asp + string font_weight = 4; + + // Text style. Possible values are normal, italic, and oblique. + // https://www.w3schools.com/cssref/pr_font_font-style.asp + string text_style = 5; + + // Text decoration. Follows CSS standard. + // + // https://www.w3schools.com/cssref/pr_text_text-decoration.asp + string text_decoration = 6; + + // Font size. + FontSize font_size = 7; + + // Font family such as `Arial`, `Times New Roman`. + // https://www.w3schools.com/cssref/pr_font_font-family.asp + string font_family = 8; + } + + // A page in a [Document][google.cloud.documentai.v1.Document]. + message Page { + // Dimension for the page. + message Dimension { + // Page width. + float width = 1; + + // Page height. + float height = 2; + + // Dimension unit. + string unit = 3; + } + + // Rendered image contents for this page. + message Image { + // Raw byte content of the image. + bytes content = 1; + + // Encoding mime type for the image. + string mime_type = 2; + + // Width of the image in pixels. + int32 width = 3; + + // Height of the image in pixels. + int32 height = 4; + } + + // Representation for transformation matrix, intended to be compatible and + // used with OpenCV format for image manipulation. + message Matrix { + // Number of rows in the matrix. + int32 rows = 1; + + // Number of columns in the matrix. + int32 cols = 2; + + // This encodes information about what data type the matrix uses. + // For example, 0 (CV_8U) is an unsigned 8-bit image. For the full list + // of OpenCV primitive data types, please refer to + // https://docs.opencv.org/4.3.0/d1/d1b/group__core__hal__interface.html + int32 type = 3; + + // The matrix data. + bytes data = 4; + } + + // Visual element describing a layout unit on a page. + message Layout { + // Detected human reading orientation. + enum Orientation { + // Unspecified orientation. + ORIENTATION_UNSPECIFIED = 0; + + // Orientation is aligned with page up. + PAGE_UP = 1; + + // Orientation is aligned with page right. + // Turn the head 90 degrees clockwise from upright to read. + PAGE_RIGHT = 2; + + // Orientation is aligned with page down. + // Turn the head 180 degrees from upright to read. + PAGE_DOWN = 3; + + // Orientation is aligned with page left. + // Turn the head 90 degrees counterclockwise from upright to read. + PAGE_LEFT = 4; + } + + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. + TextAnchor text_anchor = 1; + + // Confidence of the current [Layout][google.cloud.documentai.v1.Document.Page.Layout] within context of the object this + // layout is for. e.g. confidence can be for a single token, a table, + // a visual element, etc. depending on context. Range `[0, 1]`. + float confidence = 2; + + // The bounding polygon for the [Layout][google.cloud.documentai.v1.Document.Page.Layout]. + BoundingPoly bounding_poly = 3; + + // Detected orientation for the [Layout][google.cloud.documentai.v1.Document.Page.Layout]. + Orientation orientation = 4; + } + + // A block has a set of lines (collected into paragraphs) that have a + // common line-spacing and orientation. + message Block { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Block][google.cloud.documentai.v1.Document.Page.Block]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + + // The history of this annotation. + Provenance provenance = 3 [deprecated = true]; + } + + // A collection of lines that a human would perceive as a paragraph. + message Paragraph { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1.Document.Page.Paragraph]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + + // The history of this annotation. + Provenance provenance = 3 [deprecated = true]; + } + + // A collection of tokens that a human would perceive as a line. + // Does not cross column boundaries, can be horizontal, vertical, etc. + message Line { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Line][google.cloud.documentai.v1.Document.Page.Line]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + + // The history of this annotation. + Provenance provenance = 3 [deprecated = true]; + } + + // A detected token. + message Token { + // Detected break at the end of a [Token][google.cloud.documentai.v1.Document.Page.Token]. + message DetectedBreak { + // Enum to denote the type of break found. + enum Type { + // Unspecified break type. + TYPE_UNSPECIFIED = 0; + + // A single whitespace. + SPACE = 1; + + // A wider whitespace. + WIDE_SPACE = 2; + + // A hyphen that indicates that a token has been split across lines. + HYPHEN = 3; + } + + // Detected break type. + Type type = 1; + } + + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Token][google.cloud.documentai.v1.Document.Page.Token]. + Layout layout = 1; + + // Detected break at the end of a [Token][google.cloud.documentai.v1.Document.Page.Token]. + DetectedBreak detected_break = 2; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 3; + + // The history of this annotation. + Provenance provenance = 4 [deprecated = true]; + } + + // A detected symbol. + message Symbol { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Symbol][google.cloud.documentai.v1.Document.Page.Symbol]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + } + + // Detected non-text visual elements e.g. checkbox, signature etc. on the + // page. + message VisualElement { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1.Document.Page.VisualElement]. + Layout layout = 1; + + // Type of the [VisualElement][google.cloud.documentai.v1.Document.Page.VisualElement]. + string type = 2; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 3; + } + + // A table representation similar to HTML table structure. + message Table { + // A row of table cells. + message TableRow { + // Cells that make up this row. + repeated TableCell cells = 1; + } + + // A cell representation inside the table. + message TableCell { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1.Document.Page.Table.TableCell]. + Layout layout = 1; + + // How many rows this cell spans. + int32 row_span = 2; + + // How many columns this cell spans. + int32 col_span = 3; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 4; + } + + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Table][google.cloud.documentai.v1.Document.Page.Table]. + Layout layout = 1; + + // Header rows of the table. + repeated TableRow header_rows = 2; + + // Body rows of the table. + repeated TableRow body_rows = 3; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 4; + + // The history of this table. + Provenance provenance = 5; + } + + // A form field detected on the page. + message FormField { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1.Document.Page.FormField] name. e.g. `Address`, `Email`, + // `Grand total`, `Phone number`, etc. + Layout field_name = 1; + + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1.Document.Page.FormField] value. + Layout field_value = 2; + + // A list of detected languages for name together with confidence. + repeated DetectedLanguage name_detected_languages = 3; + + // A list of detected languages for value together with confidence. + repeated DetectedLanguage value_detected_languages = 4; + + // If the value is non-textual, this field represents the type. Current + // valid values are: + // - blank (this indicates the field_value is normal text) + // - "unfilled_checkbox" + // - "filled_checkbox" + string value_type = 5; + + // Created for Labeling UI to export key text. + // If corrections were made to the text identified by the + // `field_name.text_anchor`, this field will contain the correction. + string corrected_key_text = 6; + + // Created for Labeling UI to export value text. + // If corrections were made to the text identified by the + // `field_value.text_anchor`, this field will contain the correction. + string corrected_value_text = 7; + + // The history of this annotation. + Provenance provenance = 8; + } + + // A detected barcode. + message DetectedBarcode { + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [DetectedBarcode][google.cloud.documentai.v1.Document.Page.DetectedBarcode]. + Layout layout = 1; + + // Detailed barcode information of the [DetectedBarcode][google.cloud.documentai.v1.Document.Page.DetectedBarcode]. + Barcode barcode = 2; + } + + // Detected language for a structural component. + message DetectedLanguage { + // The BCP-47 language code, such as `en-US` or `sr-Latn`. For more + // information, see + // https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 1; + + // Confidence of detected language. Range `[0, 1]`. + float confidence = 2; + } + + // Image Quality Scores for the page image + message ImageQualityScores { + // Image Quality Defects + message DetectedDefect { + // Name of the defect type. Supported values are: + // + // - `quality/defect_blurry` + // - `quality/defect_noisy` + // - `quality/defect_dark` + // - `quality/defect_faint` + // - `quality/defect_text_too_small` + // - `quality/defect_document_cutoff` + // - `quality/defect_text_cutoff` + // - `quality/defect_glare` + string type = 1; + + // Confidence of detected defect. Range `[0, 1]` where 1 indicates + // strong confidence of that the defect exists. + float confidence = 2; + } + + // The overall quality score. Range `[0, 1]` where 1 is perfect quality. + float quality_score = 1; + + // A list of detected defects. + repeated DetectedDefect detected_defects = 2; + } + + // 1-based index for current [Page][google.cloud.documentai.v1.Document.Page] in a parent [Document][google.cloud.documentai.v1.Document]. + // Useful when a page is taken out of a [Document][google.cloud.documentai.v1.Document] for individual + // processing. + int32 page_number = 1; + + // Rendered image for this page. This image is preprocessed to remove any + // skew, rotation, and distortions such that the annotation bounding boxes + // can be upright and axis-aligned. + Image image = 13; + + // Transformation matrices that were applied to the original document image + // to produce [Page.image][google.cloud.documentai.v1.Document.Page.image]. + repeated Matrix transforms = 14; + + // Physical dimension of the page. + Dimension dimension = 2; + + // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the page. + Layout layout = 3; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 4; + + // A list of visually detected text blocks on the page. + // A block has a set of lines (collected into paragraphs) that have a common + // line-spacing and orientation. + repeated Block blocks = 5; + + // A list of visually detected text paragraphs on the page. + // A collection of lines that a human would perceive as a paragraph. + repeated Paragraph paragraphs = 6; + + // A list of visually detected text lines on the page. + // A collection of tokens that a human would perceive as a line. + repeated Line lines = 7; + + // A list of visually detected tokens on the page. + repeated Token tokens = 8; + + // A list of detected non-text visual elements e.g. checkbox, + // signature etc. on the page. + repeated VisualElement visual_elements = 9; + + // A list of visually detected tables on the page. + repeated Table tables = 10; + + // A list of visually detected form fields on the page. + repeated FormField form_fields = 11; + + // A list of visually detected symbols on the page. + repeated Symbol symbols = 12; + + // A list of detected barcodes. + repeated DetectedBarcode detected_barcodes = 15; + + // Image Quality Scores. + ImageQualityScores image_quality_scores = 17; + + // The history of this page. + Provenance provenance = 16 [deprecated = true]; + } + + // An entity that could be a phrase in the text or a property that belongs to + // the document. It is a known entity type, such as a person, an organization, + // or location. + message Entity { + // Parsed and normalized entity value. + message NormalizedValue { + // An optional structured entity value. + // Must match entity type defined in schema if + // known. If this field is present, the `text` field could also be + // populated. + oneof structured_value { + // Money value. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/money.proto + google.type.Money money_value = 2; + + // Date value. Includes year, month, day. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/date.proto + google.type.Date date_value = 3; + + // DateTime value. Includes date, time, and timezone. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto + google.type.DateTime datetime_value = 4; + + // Postal address. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto + google.type.PostalAddress address_value = 5; + + // Boolean value. Can be used for entities with binary values, or for + // checkboxes. + bool boolean_value = 6; + + // Integer value. + int32 integer_value = 7; + + // Float value. + float float_value = 8; + } + + // Optional. An optional field to store a normalized string. + // For some entity types, one of respective `structured_value` fields may + // also be populated. Also not all the types of `structured_value` will be + // normalized. For example, some processors may not generate float + // or int normalized text by default. + // + // Below are sample formats mapped to structured values. + // + // - Money/Currency type (`money_value`) is in the ISO 4217 text format. + // - Date type (`date_value`) is in the ISO 8601 text format. + // - Datetime type (`datetime_value`) is in the ISO 8601 text format. + string text = 1 [(google.api.field_behavior) = OPTIONAL]; + } + + // Optional. Provenance of the entity. + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. + TextAnchor text_anchor = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Entity type from a schema e.g. `Address`. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`. + string mention_text = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Deprecated. Use `id` field instead. + string mention_id = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Confidence of detected Schema entity. Range `[0, 1]`. + float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Represents the provenance of this entity wrt. the location on the + // page where it was found. + PageAnchor page_anchor = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Canonical id. This will be a unique value in the entity list + // for this document. + string id = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Normalized entity value. Absent if the extracted value could not be + // converted or the type (e.g. address) is not supported for certain + // parsers. This field is also only populated for certain supported document + // types. + NormalizedValue normalized_value = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Entities can be nested to form a hierarchical data structure representing + // the content in the document. + repeated Entity properties = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The history of this annotation. + Provenance provenance = 11 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Whether the entity will be redacted for de-identification purposes. + bool redacted = 12 [(google.api.field_behavior) = OPTIONAL]; + } + + // Relationship between [Entities][google.cloud.documentai.v1.Document.Entity]. + message EntityRelation { + // Subject entity id. + string subject_id = 1; + + // Object entity id. + string object_id = 2; + + // Relationship description. + string relation = 3; + } + + // Text reference indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. + message TextAnchor { + // A text segment in the [Document.text][google.cloud.documentai.v1.Document.text]. The indices may be out of bounds + // which indicate that the text extends into another document shard for + // large sharded documents. See [ShardInfo.text_offset][google.cloud.documentai.v1.Document.ShardInfo.text_offset] + message TextSegment { + // [TextSegment][google.cloud.documentai.v1.Document.TextAnchor.TextSegment] start UTF-8 char index in the [Document.text][google.cloud.documentai.v1.Document.text]. + int64 start_index = 1; + + // [TextSegment][google.cloud.documentai.v1.Document.TextAnchor.TextSegment] half open end UTF-8 char index in the + // [Document.text][google.cloud.documentai.v1.Document.text]. + int64 end_index = 2; + } + + // The text segments from the [Document.text][google.cloud.documentai.v1.Document.text]. + repeated TextSegment text_segments = 1; + + // Contains the content of the text span so that users do + // not have to look it up in the text_segments. It is always + // populated for formFields. + string content = 2; + } + + // Referencing the visual context of the entity in the [Document.pages][google.cloud.documentai.v1.Document.pages]. + // Page anchors can be cross-page, consist of multiple bounding polygons and + // optionally reference specific layout element types. + message PageAnchor { + // Represents a weak reference to a page element within a document. + message PageRef { + // The type of layout that is being referenced. + enum LayoutType { + // Layout Unspecified. + LAYOUT_TYPE_UNSPECIFIED = 0; + + // References a [Page.blocks][google.cloud.documentai.v1.Document.Page.blocks] element. + BLOCK = 1; + + // References a [Page.paragraphs][google.cloud.documentai.v1.Document.Page.paragraphs] element. + PARAGRAPH = 2; + + // References a [Page.lines][google.cloud.documentai.v1.Document.Page.lines] element. + LINE = 3; + + // References a [Page.tokens][google.cloud.documentai.v1.Document.Page.tokens] element. + TOKEN = 4; + + // References a [Page.visual_elements][google.cloud.documentai.v1.Document.Page.visual_elements] element. + VISUAL_ELEMENT = 5; + + // Refrrences a [Page.tables][google.cloud.documentai.v1.Document.Page.tables] element. + TABLE = 6; + + // References a [Page.form_fields][google.cloud.documentai.v1.Document.Page.form_fields] element. + FORM_FIELD = 7; + } + + // Required. Index into the [Document.pages][google.cloud.documentai.v1.Document.pages] element, for example using + // [Document.pages][page_refs.page] to locate the related page element. + // This field is skipped when its value is the default 0. See + // https://developers.google.com/protocol-buffers/docs/proto3#json. + int64 page = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The type of the layout element that is being referenced if any. + LayoutType layout_type = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Deprecated. Use [PageRef.bounding_poly][google.cloud.documentai.v1.Document.PageAnchor.PageRef.bounding_poly] instead. + string layout_id = 3 [ + deprecated = true, + (google.api.field_behavior) = OPTIONAL + ]; + + // Optional. Identifies the bounding polygon of a layout element on the page. + BoundingPoly bounding_poly = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Confidence of detected page element, if applicable. Range `[0, 1]`. + float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; + } + + // One or more references to visual page elements + repeated PageRef page_refs = 1; + } + + // Structure to identify provenance relationships between annotations in + // different revisions. + message Provenance { + // The parent element the current element is based on. Used for + // referencing/aligning, removal and replacement operations. + message Parent { + // The index of the index into current revision's parent_ids list. + int32 revision = 1; + + // The index of the parent item in the corresponding item list (eg. list + // of entities, properties within entities, etc.) in the parent revision. + int32 index = 3; + + // The id of the parent provenance. + int32 id = 2 [deprecated = true]; + } + + // If a processor or agent does an explicit operation on existing elements. + enum OperationType { + // Operation type unspecified. If no operation is specified a provenance + // entry is simply used to match against a `parent`. + OPERATION_TYPE_UNSPECIFIED = 0; + + // Add an element. + ADD = 1; + + // Remove an element identified by `parent`. + REMOVE = 2; + + // Replace an element identified by `parent`. + REPLACE = 3; + + // Request human review for the element identified by `parent`. + EVAL_REQUESTED = 4; + + // Element is reviewed and approved at human review, confidence will be + // set to 1.0. + EVAL_APPROVED = 5; + + // Element is skipped in the validation process. + EVAL_SKIPPED = 6; + } + + // The index of the revision that produced this element. + int32 revision = 1; + + // The Id of this operation. Needs to be unique within the scope of the + // revision. + int32 id = 2 [deprecated = true]; + + // References to the original elements that are replaced. + repeated Parent parents = 3; + + // The type of provenance operation. + OperationType type = 4; + } + + // Contains past or forward revisions of this document. + message Revision { + // Human Review information of the document. + message HumanReview { + // Human review state. e.g. `requested`, `succeeded`, `rejected`. + string state = 1; + + // A message providing more details about the current state of processing. + // For example, the rejection reason when the state is `rejected`. + string state_message = 2; + } + + // Who/what made the change + oneof source { + // If the change was made by a person specify the name or id of that + // person. + string agent = 4; + + // If the annotation was made by processor identify the processor by its + // resource name. + string processor = 5; + } + + // Id of the revision. Unique within the context of the document. + string id = 1; + + // The revisions that this revision is based on. This can include one or + // more parent (when documents are merged.) This field represents the + // index into the `revisions` field. + repeated int32 parent = 2 [deprecated = true]; + + // The revisions that this revision is based on. Must include all the ids + // that have anything to do with this revision - eg. there are + // `provenance.parent.revision` fields that index into this field. + repeated string parent_ids = 7; + + // The time that the revision was created. + google.protobuf.Timestamp create_time = 3; + + // Human Review information of this revision. + HumanReview human_review = 6; + } + + // This message is used for text changes aka. OCR corrections. + message TextChange { + // Provenance of the correction. + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. There can only be a + // single `TextAnchor.text_segments` element. If the start and + // end index of the text segment are the same, the text change is inserted + // before that index. + TextAnchor text_anchor = 1; + + // The text that replaces the text identified in the `text_anchor`. + string changed_text = 2; + + // The history of this annotation. + repeated Provenance provenance = 3 [deprecated = true]; + } + + // Original source document from the user. + oneof source { + // Optional. Currently supports Google Cloud Storage URI of the form + // `gs://bucket_name/object_name`. Object versioning is not supported. + // See [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris) for more + // info. + string uri = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Inline document content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + bytes content = 2 [(google.api.field_behavior) = OPTIONAL]; + } + + // An IANA published MIME type (also referred to as media type). For more + // information, see + // https://www.iana.org/assignments/media-types/media-types.xhtml. + string mime_type = 3; + + // Optional. UTF-8 encoded text in reading order from the document. + string text = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Placeholder. Styles for the [Document.text][google.cloud.documentai.v1.Document.text]. + repeated Style text_styles = 5; + + // Visual page layout for the [Document][google.cloud.documentai.v1.Document]. + repeated Page pages = 6; + + // A list of entities detected on [Document.text][google.cloud.documentai.v1.Document.text]. For document shards, + // entities in this list may cross shard boundaries. + repeated Entity entities = 7; + + // Placeholder. Relationship among [Document.entities][google.cloud.documentai.v1.Document.entities]. + repeated EntityRelation entity_relations = 8; + + // Placeholder. A list of text corrections made to [Document.text][google.cloud.documentai.v1.Document.text]. This + // is usually used for annotating corrections to OCR mistakes. Text changes + // for a given revision may not overlap with each other. + repeated TextChange text_changes = 14; + + // Information about the sharding if this document is sharded part of a larger + // document. If the document is not sharded, this message is not specified. + ShardInfo shard_info = 9; + + // Any error that occurred while processing this document. + google.rpc.Status error = 10; + + // Placeholder. Revision history of this document. + repeated Revision revisions = 13; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_io.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_io.proto new file mode 100644 index 00000000000..3240d494e8f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_io.proto @@ -0,0 +1,91 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentIoProto"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// Payload message of raw document content (bytes). +message RawDocument { + // Inline document content. + bytes content = 1; + + // An IANA MIME type (RFC6838) indicating the nature and format of the + // [content][google.cloud.documentai.v1.RawDocument.content]. + string mime_type = 2; +} + +// Specifies a document stored on Cloud Storage. +message GcsDocument { + // The Cloud Storage object uri. + string gcs_uri = 1; + + // An IANA MIME type (RFC6838) of the content. + string mime_type = 2; +} + +// Specifies a set of documents on Cloud Storage. +message GcsDocuments { + // The list of documents. + repeated GcsDocument documents = 1; +} + +// Specifies all documents on Cloud Storage with a common prefix. +message GcsPrefix { + // The URI prefix. + string gcs_uri_prefix = 1; +} + +// The common config to specify a set of documents used as input. +message BatchDocumentsInputConfig { + // The source. + oneof source { + // The set of documents that match the specified Cloud Storage `gcs_prefix`. + GcsPrefix gcs_prefix = 1; + + // The set of documents individually specified on Cloud Storage. + GcsDocuments gcs_documents = 2; + } +} + +// Config that controls the output of documents. All documents will be written +// as a JSON file. +message DocumentOutputConfig { + // The configuration used when outputting documents. + message GcsOutputConfig { + // The Cloud Storage uri (a directory) of the output. + string gcs_uri = 1; + + // Specifies which fields to include in the output documents. + // Only supports top level document and pages field so it must be in the + // form of `{document_field_name}` or `pages.{page_field_name}`. + google.protobuf.FieldMask field_mask = 2; + } + + // The destination of the results. + oneof destination { + // Output config to write the results to Cloud Storage. + GcsOutputConfig gcs_output_config = 1; + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_processor_service.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_processor_service.proto new file mode 100644 index 00000000000..e748ae1f748 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_processor_service.proto @@ -0,0 +1,801 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/documentai/v1/document.proto"; +import "google/cloud/documentai/v1/document_io.proto"; +import "google/cloud/documentai/v1/document_schema.proto"; +import "google/cloud/documentai/v1/operation_metadata.proto"; +import "google/cloud/documentai/v1/processor.proto"; +import "google/cloud/documentai/v1/processor_type.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProcessorService"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; +option (google.api.resource_definition) = { + type: "documentai.googleapis.com/HumanReviewConfig" + pattern: "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" +}; +option (google.api.resource_definition) = { + type: "documentai.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; + +// Service to call Cloud DocumentAI to process documents according to the +// processor's definition. Processors are built using state-of-the-art Google +// AI such as natural language, computer vision, and translation to extract +// structured information from unstructured or semi-structured documents. +service DocumentProcessorService { + option (google.api.default_host) = "documentai.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Processes a single document. + rpc ProcessDocument(ProcessRequest) returns (ProcessResponse) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*}:process" + body: "*" + additional_bindings { + post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:process" + body: "*" + } + }; + option (google.api.method_signature) = "name"; + } + + // LRO endpoint to batch process many documents. The output is written + // to Cloud Storage as JSON in the [Document] format. + rpc BatchProcessDocuments(BatchProcessRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*}:batchProcess" + body: "*" + additional_bindings { + post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:batchProcess" + body: "*" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "BatchProcessResponse" + metadata_type: "BatchProcessMetadata" + }; + } + + // Fetches processor types. Note that we do not use ListProcessorTypes here + // because it is not paginated. + rpc FetchProcessorTypes(FetchProcessorTypesRequest) returns (FetchProcessorTypesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}:fetchProcessorTypes" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists the processor types that exist. + rpc ListProcessorTypes(ListProcessorTypesRequest) returns (ListProcessorTypesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/processorTypes" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists all processors which belong to this project. + rpc ListProcessors(ListProcessorsRequest) returns (ListProcessorsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/processors" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a processor detail. + rpc GetProcessor(GetProcessorRequest) returns (Processor) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/processors/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets a processor version detail. + rpc GetProcessorVersion(GetProcessorVersionRequest) returns (ProcessorVersion) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all versions of a processor. + rpc ListProcessorVersions(ListProcessorVersionsRequest) returns (ListProcessorVersionsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/processors/*}/processorVersions" + }; + option (google.api.method_signature) = "parent"; + } + + // Deletes the processor version, all artifacts under the processor version + // will be deleted. + rpc DeleteProcessorVersion(DeleteProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "DeleteProcessorVersionMetadata" + }; + } + + // Deploys the processor version. + rpc DeployProcessorVersion(DeployProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:deploy" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "DeployProcessorVersionResponse" + metadata_type: "DeployProcessorVersionMetadata" + }; + } + + // Undeploys the processor version. + rpc UndeployProcessorVersion(UndeployProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:undeploy" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "UndeployProcessorVersionResponse" + metadata_type: "UndeployProcessorVersionMetadata" + }; + } + + // Creates a processor from the type processor that the user chose. + // The processor will be at "ENABLED" state by default after its creation. + rpc CreateProcessor(CreateProcessorRequest) returns (Processor) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/processors" + body: "processor" + }; + option (google.api.method_signature) = "parent,processor"; + } + + // Deletes the processor, unloads all deployed model artifacts if it was + // enabled and then deletes all artifacts associated with this processor. + rpc DeleteProcessor(DeleteProcessorRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/processors/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "DeleteProcessorMetadata" + }; + } + + // Enables a processor + rpc EnableProcessor(EnableProcessorRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*}:enable" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "EnableProcessorResponse" + metadata_type: "EnableProcessorMetadata" + }; + } + + // Disables a processor + rpc DisableProcessor(DisableProcessorRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/processors/*}:disable" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "DisableProcessorResponse" + metadata_type: "DisableProcessorMetadata" + }; + } + + // Set the default (active) version of a [Processor][google.cloud.documentai.v1.Processor] that will be used in + // [ProcessDocument][google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument] and + // [BatchProcessDocuments][google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments]. + rpc SetDefaultProcessorVersion(SetDefaultProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{processor=projects/*/locations/*/processors/*}:setDefaultProcessorVersion" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "SetDefaultProcessorVersionResponse" + metadata_type: "SetDefaultProcessorVersionMetadata" + }; + } + + // Send a document for Human Review. The input document should be processed by + // the specified processor. + rpc ReviewDocument(ReviewDocumentRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{human_review_config=projects/*/locations/*/processors/*/humanReviewConfig}:reviewDocument" + body: "*" + }; + option (google.api.method_signature) = "human_review_config"; + option (google.longrunning.operation_info) = { + response_type: "ReviewDocumentResponse" + metadata_type: "ReviewDocumentOperationMetadata" + }; + } +} + +// Request message for the process document method. +message ProcessRequest { + // The document payload. + oneof source { + // An inline document proto. + Document inline_document = 4; + + // A raw document content (bytes). + RawDocument raw_document = 5; + } + + // Required. The resource name of the [Processor][google.cloud.documentai.v1.Processor] or + // [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] + // to use for processing. If a [Processor][google.cloud.documentai.v1.Processor] is specified, the server will use + // its [default version][google.cloud.documentai.v1.Processor.default_processor_version]. Format: + // `projects/{project}/locations/{location}/processors/{processor}`, or + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "*" + } + ]; + + // Whether Human Review feature should be skipped for this request. Default to + // false. + bool skip_human_review = 3; + + // Specifies which fields to include in ProcessResponse's document. + // Only supports top level document and pages field so it must be in the form + // of `{document_field_name}` or `pages.{page_field_name}`. + google.protobuf.FieldMask field_mask = 6; +} + +// The status of human review on a processed document. +message HumanReviewStatus { + // The final state of human review on a processed document. + enum State { + // Human review state is unspecified. Most likely due to an internal error. + STATE_UNSPECIFIED = 0; + + // Human review is skipped for the document. This can happen because human + // review is not enabled on the processor or the processing request has + // been set to skip this document. + SKIPPED = 1; + + // Human review validation is triggered and passed, so no review is needed. + VALIDATION_PASSED = 2; + + // Human review validation is triggered and the document is under review. + IN_PROGRESS = 3; + + // Some error happened during triggering human review, see the + // [state_message] for details. + ERROR = 4; + } + + // The state of human review on the processing request. + State state = 1; + + // A message providing more details about the human review state. + string state_message = 2; + + // The name of the operation triggered by the processed document. This field + // is populated only when the [state] is [HUMAN_REVIEW_IN_PROGRESS]. It has + // the same response type and metadata as the long running operation returned + // by [ReviewDocument] method. + string human_review_operation = 3; +} + +// Response message for the process document method. +message ProcessResponse { + // The document payload, will populate fields based on the processor's + // behavior. + Document document = 1; + + // The status of human review on the processed document. + HumanReviewStatus human_review_status = 3; +} + +// Request message for batch process document method. +message BatchProcessRequest { + // Required. The resource name of [Processor][google.cloud.documentai.v1.Processor] or + // [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion]. + // Format: `projects/{project}/locations/{location}/processors/{processor}`, + // or + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "*" + } + ]; + + // The input documents for batch process. + BatchDocumentsInputConfig input_documents = 5; + + // The overall output config for batch process. + DocumentOutputConfig document_output_config = 6; + + // Whether Human Review feature should be skipped for this request. Default to + // false. + bool skip_human_review = 4; +} + +// Response message for batch process document method. +message BatchProcessResponse { + +} + +// The long running operation metadata for batch process method. +message BatchProcessMetadata { + // The status of a each individual document in the batch process. + message IndividualProcessStatus { + // The source of the document, same as the [input_gcs_source] field in the + // request when the batch process started. The batch process is started by + // take snapshot of that document, since a user can move or change that + // document during the process. + string input_gcs_source = 1; + + // The status processing the document. + google.rpc.Status status = 2; + + // The output_gcs_destination (in the request as `output_gcs_destination`) + // of the processed document if it was successful, otherwise empty. + string output_gcs_destination = 3; + + // The status of human review on the processed document. + HumanReviewStatus human_review_status = 5; + } + + // Possible states of the batch processing operation. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // Request operation is waiting for scheduling. + WAITING = 1; + + // Request is being processed. + RUNNING = 2; + + // The batch processing completed successfully. + SUCCEEDED = 3; + + // The batch processing was being cancelled. + CANCELLING = 4; + + // The batch processing was cancelled. + CANCELLED = 5; + + // The batch processing has failed. + FAILED = 6; + } + + // The state of the current batch processing. + State state = 1; + + // A message providing more details about the current state of processing. + // For example, the error message if the operation is failed. + string state_message = 2; + + // The creation time of the operation. + google.protobuf.Timestamp create_time = 3; + + // The last update time of the operation. + google.protobuf.Timestamp update_time = 4; + + // The list of response details of each document. + repeated IndividualProcessStatus individual_process_statuses = 5; +} + +// Request message for fetch processor types. +message FetchProcessorTypesRequest { + // Required. The project of processor type to list. + // The available processor types may depend on the allow-listing on projects. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorType" + } + ]; +} + +// Response message for fetch processor types. +message FetchProcessorTypesResponse { + // The list of processor types. + repeated ProcessorType processor_types = 1; +} + +// Request message for list processor types. +message ListProcessorTypesRequest { + // Required. The location of processor type to list. + // The available processor types may depend on the allow-listing on projects. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorType" + } + ]; + + // The maximum number of processor types to return. + // If unspecified, at most 100 processor types will be returned. + // The maximum value is 500; values above 500 will be coerced to 500. + int32 page_size = 2; + + // Used to retrieve the next page of results, empty if at the end of the list. + string page_token = 3; +} + +// Response message for list processor types. +message ListProcessorTypesResponse { + // The processor types. + repeated ProcessorType processor_types = 1; + + // Points to the next page, otherwise empty. + string next_page_token = 2; +} + +// Request message for list all processors belongs to a project. +message ListProcessorsRequest { + // Required. The parent (project and location) which owns this collection of Processors. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/Processor" + } + ]; + + // The maximum number of processors to return. + // If unspecified, at most 50 processors will be returned. + // The maximum value is 100; values above 100 will be coerced to 100. + int32 page_size = 2; + + // We will return the processors sorted by creation time. The page token + // will point to the next processor. + string page_token = 3; +} + +// Response message for list processors. +message ListProcessorsResponse { + // The list of processors. + repeated Processor processors = 1; + + // Points to the next processor, otherwise empty. + string next_page_token = 2; +} + +// Request message for get processor. +message GetProcessorRequest { + // Required. The processor resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// Request message for get processor version. +message GetProcessorVersionRequest { + // Required. The processor resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Request message for list all processor versions belongs to a processor. +message ListProcessorVersionsRequest { + // Required. The parent (project, location and processor) to list all versions. + // Format: `projects/{project}/locations/{location}/processors/{processor}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorVersion" + } + ]; + + // The maximum number of processor versions to return. + // If unspecified, at most 10 processor versions will be returned. + // The maximum value is 20; values above 20 will be coerced to 20. + int32 page_size = 2; + + // We will return the processor versions sorted by creation time. The page + // token will point to the next processor version. + string page_token = 3; +} + +// Response message for list processors. +message ListProcessorVersionsResponse { + // The list of processors. + repeated ProcessorVersion processor_versions = 1; + + // Points to the next processor, otherwise empty. + string next_page_token = 2; +} + +// Request message for the delete processor version method. +message DeleteProcessorVersionRequest { + // Required. The processor version resource name to be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// The long running operation metadata for delete processor version method. +message DeleteProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for the deploy processor version method. +message DeployProcessorVersionRequest { + // Required. The processor version resource name to be deployed. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Response message for the deploy processor version method. +message DeployProcessorVersionResponse { + +} + +// The long running operation metadata for deploy processor version method. +message DeployProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for the undeploy processor version method. +message UndeployProcessorVersionRequest { + // Required. The processor version resource name to be undeployed. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Response message for the undeploy processor version method. +message UndeployProcessorVersionResponse { + +} + +// The long running operation metadata for the undeploy processor version +// method. +message UndeployProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for create a processor. Notice this request is sent to +// a regionalized backend service, and if the processor type is not available +// on that region, the creation will fail. +message CreateProcessorRequest { + // Required. The parent (project and location) under which to create the processor. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/Processor" + } + ]; + + // Required. The processor to be created, requires [processor_type] and [display_name] + // to be set. Also, the processor is under CMEK if CMEK fields are set. + Processor processor = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for the delete processor method. +message DeleteProcessorRequest { + // Required. The processor resource name to be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// The long running operation metadata for delete processor method. +message DeleteProcessorMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} + +// Request message for the enable processor method. +message EnableProcessorRequest { + // Required. The processor resource name to be enabled. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// Response message for the enable processor method. +// Intentionally empty proto for adding fields in future. +message EnableProcessorResponse { + +} + +// The long running operation metadata for enable processor method. +message EnableProcessorMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} + +// Request message for the disable processor method. +message DisableProcessorRequest { + // Required. The processor resource name to be disabled. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// Response message for the disable processor method. +// Intentionally empty proto for adding fields in future. +message DisableProcessorResponse { + +} + +// The long running operation metadata for disable processor method. +message DisableProcessorMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} + +// Request message for the set default processor version method. +message SetDefaultProcessorVersionRequest { + // Required. The resource name of the [Processor][google.cloud.documentai.v1.Processor] to change default version. + string processor = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; + + // Required. The resource name of child [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] to use as default. + // Format: + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` + string default_processor_version = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Response message for set default processor version method. +message SetDefaultProcessorVersionResponse { + +} + +// The long running operation metadata for set default processor version +// method. +message SetDefaultProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for review document method. +message ReviewDocumentRequest { + // The priority level of the human review task. + enum Priority { + // The default priority level. + DEFAULT = 0; + + // The urgent priority level. The labeling manager should allocate labeler + // resource to the urgent task queue to respect this priority level. + URGENT = 1; + } + + // The document payload. + oneof source { + // An inline document proto. + Document inline_document = 4; + } + + // Required. The resource name of the HumanReviewConfig that the document will be + // reviewed with. + string human_review_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/HumanReviewConfig" + } + ]; + + // Whether the validation should be performed on the ad-hoc review request. + bool enable_schema_validation = 3; + + // The priority of the human review task. + Priority priority = 5; + + // The document schema of the human review task. + DocumentSchema document_schema = 6; +} + +// Response message for review document method. +message ReviewDocumentResponse { + // Possible states of the review operation. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // The review operation is rejected by the reviewer. + REJECTED = 1; + + // The review operation is succeeded. + SUCCEEDED = 2; + } + + // The Cloud Storage uri for the human reviewed document if the review is + // succeeded. + string gcs_destination = 1; + + // The state of the review operation. + State state = 2; + + // The reason why the review is rejected by reviewer. + string rejection_reason = 3; +} + +// The long running operation metadata for review document method. +message ReviewDocumentOperationMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; + + // The Crowd Compute question ID. + string question_id = 6; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_schema.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_schema.proto new file mode 100644 index 00000000000..ceb25a1d69a --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_schema.proto @@ -0,0 +1,141 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiDocumentSchema"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// The schema defines the output of the processed document by a processor. +message DocumentSchema { + // EntityType is the wrapper of a label of the corresponding model with + // detailed attributes and limitations for entity-based processors. Multiple + // types can also compose a dependency tree to represent nested types. + message EntityType { + // Defines the a list of enum values. + message EnumValues { + // The individual values that this enum values type can include. + repeated string values = 1; + } + + // Defines properties that can be part of the entity type. + message Property { + // Types of occurrences of the entity type in the document. Note: this + // represents the number of instances of an entity types, not number of + // mentions of a given entity instance. + enum OccurrenceType { + // Unspecified occurrence type. + OCCURRENCE_TYPE_UNSPECIFIED = 0; + + // There will be zero or one instance of this entity type. + OPTIONAL_ONCE = 1; + + // The entity type will appear zero or multiple times. + OPTIONAL_MULTIPLE = 2; + + // The entity type will only appear exactly once. + REQUIRED_ONCE = 3; + + // The entity type will appear once or more times. + REQUIRED_MULTIPLE = 4; + } + + // The name of the property. Follows the same guidelines as the + // EntityType name. + string name = 1; + + // A reference to the value type of the property. This type is subject + // to the same conventions as the `Entity.base_types` field. + string value_type = 2; + + // Occurrence type limits the number of instances an entity type appears + // in the document. + OccurrenceType occurrence_type = 3; + } + + oneof value_source { + // If specified, lists all the possible values for this entity. This + // should not be more than a handful of values. If the number of values + // is >10 or could change frequently use the `EntityType.value_ontology` + // field and specify a list of all possible values in a value ontology + // file. + EnumValues enum_values = 14; + } + + // User defined name for the type. + string display_name = 13; + + // Name of the type. It must be unique within the schema file and + // cannot be a 'Common Type'. Besides that we use the following naming + // conventions: + // + // - *use `snake_casing`* + // - name matching is case-insensitive + // - Maximum 64 characters. + // - Must start with a letter. + // - Allowed characters: ASCII letters `[a-z0-9_-]`. (For backward + // compatibility internal infrastructure and tooling can handle any ascii + // character) + // - The `/` is sometimes used to denote a property of a type. For example + // `line_item/amount`. This convention is deprecated, but will still be + // honored for backward compatibility. + string name = 1; + + // The entity type that this type is derived from. For now, one and only + // one should be set. + repeated string base_types = 2; + + // Describing the nested structure, or composition of an entity. + repeated Property properties = 6; + } + + // Metadata for global schema behavior. + message Metadata { + // If true, a `document` entity type can be applied to subdocument ( + // splitting). Otherwise, it can only be applied to the entire document + // (classification). + bool document_splitter = 1; + + // If true, on a given page, there can be multiple `document` annotations + // covering it. + bool document_allow_multiple_labels = 2; + + // If set, all the nested entities must be prefixed with the parents. + bool prefixed_naming_on_properties = 6; + + // If set, we will skip the naming format validation in the schema. So the + // string values in `DocumentSchema.EntityType.name` and + // `DocumentSchema.EntityType.Property.name` will not be checked. + bool skip_naming_validation = 7; + } + + // Display name to show to users. + string display_name = 1; + + // Description of the schema. + string description = 2; + + // Entity types of the schema. + repeated EntityType entity_types = 3; + + // Metadata of the schema. + Metadata metadata = 4; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/geometry.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/geometry.proto new file mode 100644 index 00000000000..7471ef01247 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/geometry.proto @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "GeometryProto"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// A vertex represents a 2D point in the image. +// NOTE: the vertex coordinates are in the same scale as the original image. +message Vertex { + // X coordinate. + int32 x = 1; + + // Y coordinate (starts from the top of the image). + int32 y = 2; +} + +// A vertex represents a 2D point in the image. +// NOTE: the normalized vertex coordinates are relative to the original image +// and range from 0 to 1. +message NormalizedVertex { + // X coordinate. + float x = 1; + + // Y coordinate (starts from the top of the image). + float y = 2; +} + +// A bounding polygon for the detected image annotation. +message BoundingPoly { + // The bounding polygon vertices. + repeated Vertex vertices = 1; + + // The bounding polygon normalized vertices. + repeated NormalizedVertex normalized_vertices = 2; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/operation_metadata.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/operation_metadata.proto new file mode 100644 index 00000000000..5698b0a4f3c --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/operation_metadata.proto @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "OperationMetadataProto"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// The common metadata for long running operations. +message CommonOperationMetadata { + // State of the longrunning operation. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // Operation is still running. + RUNNING = 1; + + // Operation is being cancelled. + CANCELLING = 2; + + // Operation succeeded. + SUCCEEDED = 3; + + // Operation failed. + FAILED = 4; + + // Operation is cancelled. + CANCELLED = 5; + } + + // The state of the operation. + State state = 1; + + // A message providing more details about the current state of processing. + string state_message = 2; + + // A related resource to this operation. + string resource = 5; + + // The creation time of the operation. + google.protobuf.Timestamp create_time = 3; + + // The last update time of the operation. + google.protobuf.Timestamp update_time = 4; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor.proto new file mode 100644 index 00000000000..3ffe6927df9 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor.proto @@ -0,0 +1,189 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/documentai/v1/document_schema.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProcessor"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// A processor version is an implementation of a processor. Each processor +// can have multiple versions, pre-trained by Google internally or up-trained +// by the customer. At a time, a processor can only have one default version +// version. So the processor's behavior (when processing documents) is defined +// by a default version +message ProcessorVersion { + option (google.api.resource) = { + type: "documentai.googleapis.com/ProcessorVersion" + pattern: "projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}" + }; + + // Information about the upcoming deprecation of this processor version. + message DeprecationInfo { + // The time at which this processor version will be deprecated. + google.protobuf.Timestamp deprecation_time = 1; + + // If set, the processor version that will be used as a replacement. + string replacement_processor_version = 2 [(google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + }]; + } + + // The possible states of the processor version. + enum State { + // The processor version is in an unspecified state. + STATE_UNSPECIFIED = 0; + + // The processor version is deployed and can be used for processing. + DEPLOYED = 1; + + // The processor version is being deployed. + DEPLOYING = 2; + + // The processor version is not deployed and cannot be used for processing. + UNDEPLOYED = 3; + + // The processor version is being undeployed. + UNDEPLOYING = 4; + + // The processor version is being created. + CREATING = 5; + + // The processor version is being deleted. + DELETING = 6; + + // The processor version failed and is in an indeterminate state. + FAILED = 7; + } + + // The resource name of the processor version. + // Format: + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}` + string name = 1; + + // The display name of the processor version. + string display_name = 2; + + // The schema of the processor version. Describes the output. + DocumentSchema document_schema = 12; + + // The state of the processor version. + State state = 6; + + // The time the processor version was created. + google.protobuf.Timestamp create_time = 7; + + // The KMS key name used for encryption. + string kms_key_name = 9; + + // The KMS key version with which data is encrypted. + string kms_key_version_name = 10; + + // Denotes that this ProcessorVersion is managed by google. + bool google_managed = 11; + + // If set, information about the eventual deprecation of this version. + DeprecationInfo deprecation_info = 13; +} + +// The first-class citizen for Document AI. Each processor defines how to +// extract structural information from a document. +message Processor { + option (google.api.resource) = { + type: "documentai.googleapis.com/Processor" + pattern: "projects/{project}/locations/{location}/processors/{processor}" + }; + + // The possible states of the processor. + enum State { + // The processor is in an unspecified state. + STATE_UNSPECIFIED = 0; + + // The processor is enabled, i.e., has an enabled version which can + // currently serve processing requests and all the feature dependencies have + // been successfully initialized. + ENABLED = 1; + + // The processor is disabled. + DISABLED = 2; + + // The processor is being enabled, will become `ENABLED` if successful. + ENABLING = 3; + + // The processor is being disabled, will become `DISABLED` if successful. + DISABLING = 4; + + // The processor is being created, will become either `ENABLED` (for + // successful creation) or `FAILED` (for failed ones). + // Once a processor is in this state, it can then be used for document + // processing, but the feature dependencies of the processor might not be + // fully created yet. + CREATING = 5; + + // The processor failed during creation or initialization of feature + // dependencies. The user should delete the processor and recreate one as + // all the functionalities of the processor are disabled. + FAILED = 6; + + // The processor is being deleted, will be removed if successful. + DELETING = 7; + } + + // Output only. Immutable. The resource name of the processor. + // Format: `projects/{project}/locations/{location}/processors/{processor}` + string name = 1 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. + // To get a list of processors types, see + // [FetchProcessorTypes][google.cloud.documentai.v1.DocumentProcessorService.FetchProcessorTypes]. + string type = 2; + + // The display name of the processor. + string display_name = 3; + + // Output only. The state of the processor. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The default processor version. + string default_processor_version = 9 [(google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + }]; + + // Output only. Immutable. The http endpoint that can be called to invoke processing. + string process_endpoint = 6 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.field_behavior) = IMMUTABLE + ]; + + // The time the processor was created. + google.protobuf.Timestamp create_time = 7; + + // The KMS key used for encryption/decryption in CMEK scenarios. + // See https://cloud.google.com/security-key-management. + string kms_key_name = 8; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor_type.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor_type.proto new file mode 100644 index 00000000000..2c9ee923051 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor_type.proto @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1; + +import "google/api/launch_stage.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.DocumentAI.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; +option java_multiple_files = true; +option java_outer_classname = "DocumentAiProcessorType"; +option java_package = "com.google.cloud.documentai.v1"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; +option ruby_package = "Google::Cloud::DocumentAI::V1"; + +// A processor type is responsible for performing a certain document +// understanding task on a certain type of document. +message ProcessorType { + option (google.api.resource) = { + type: "documentai.googleapis.com/ProcessorType" + pattern: "projects/{project}/locations/{location}/processorTypes/{processor_type}" + }; + + // The location information about where the processor is available. + message LocationInfo { + // The location id, currently must be one of [us, eu]. + string location_id = 1; + } + + // The resource name of the processor type. + // Format: `projects/{project}/processorTypes/{processor_type}` + string name = 1; + + // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. + string type = 2; + + // The processor category, used by UI to group processor types. + string category = 3; + + // The locations in which this processor is available. + repeated LocationInfo available_locations = 4; + + // Whether the processor type allows creation. If true, users can create a + // processor of this processor type. Otherwise, users need to request access. + bool allow_creation = 6; + + // Launch stage of the processor type + google.api.LaunchStage launch_stage = 8; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.batch_process_documents.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.batch_process_documents.js new file mode 100644 index 00000000000..c099efd7b6c --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.batch_process_documents.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of Processor google.cloud.documentai.v1.Processor or + * ProcessorVersion google.cloud.documentai.v1.ProcessorVersion. + * Format: `projects/{project}/locations/{location}/processors/{processor}`, + * or + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + */ + // const name = 'abc123' + /** + * The input documents for batch process. + */ + // const inputDocuments = {} + /** + * The overall output config for batch process. + */ + // const documentOutputConfig = {} + /** + * Whether Human Review feature should be skipped for this request. Default to + * false. + */ + // const skipHumanReview = true + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callBatchProcessDocuments() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.batchProcessDocuments(request); + const [response] = await operation.promise(); + console.log(response); + } + + callBatchProcessDocuments(); + // [END documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.create_processor.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.create_processor.js new file mode 100644 index 00000000000..24da55f864f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.create_processor.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, processor) { + // [START documentai_v1_generated_DocumentProcessorService_CreateProcessor_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent (project and location) under which to create the processor. + * Format: `projects/{project}/locations/{location}` + */ + // const parent = 'abc123' + /** + * 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. + */ + // const processor = {} + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callCreateProcessor() { + // Construct request + const request = { + parent, + processor, + }; + + // Run request + const response = await documentaiClient.createProcessor(request); + console.log(response); + } + + callCreateProcessor(); + // [END documentai_v1_generated_DocumentProcessorService_CreateProcessor_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor.js new file mode 100644 index 00000000000..2c087b70d5b --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1_generated_DocumentProcessorService_DeleteProcessor_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor resource name to be deleted. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callDeleteProcessor() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.deleteProcessor(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteProcessor(); + // [END documentai_v1_generated_DocumentProcessorService_DeleteProcessor_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor_version.js new file mode 100644 index 00000000000..2f19c69d877 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor_version.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1_generated_DocumentProcessorService_DeleteProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor version resource name to be deleted. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callDeleteProcessorVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.deleteProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteProcessorVersion(); + // [END documentai_v1_generated_DocumentProcessorService_DeleteProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.deploy_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.deploy_processor_version.js new file mode 100644 index 00000000000..09379736014 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.deploy_processor_version.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1_generated_DocumentProcessorService_DeployProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor version resource name to be deployed. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callDeployProcessorVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.deployProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeployProcessorVersion(); + // [END documentai_v1_generated_DocumentProcessorService_DeployProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.disable_processor.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.disable_processor.js new file mode 100644 index 00000000000..80a52d09a2e --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.disable_processor.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1_generated_DocumentProcessorService_DisableProcessor_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor resource name to be disabled. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callDisableProcessor() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.disableProcessor(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDisableProcessor(); + // [END documentai_v1_generated_DocumentProcessorService_DisableProcessor_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.enable_processor.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.enable_processor.js new file mode 100644 index 00000000000..8d66f45c069 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.enable_processor.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1_generated_DocumentProcessorService_EnableProcessor_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor resource name to be enabled. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callEnableProcessor() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.enableProcessor(request); + const [response] = await operation.promise(); + console.log(response); + } + + callEnableProcessor(); + // [END documentai_v1_generated_DocumentProcessorService_EnableProcessor_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.fetch_processor_types.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.fetch_processor_types.js new file mode 100644 index 00000000000..5bb5c2383e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.fetch_processor_types.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START documentai_v1_generated_DocumentProcessorService_FetchProcessorTypes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + */ + // const parent = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callFetchProcessorTypes() { + // Construct request + const request = { + parent, + }; + + // Run request + const response = await documentaiClient.fetchProcessorTypes(request); + console.log(response); + } + + callFetchProcessorTypes(); + // [END documentai_v1_generated_DocumentProcessorService_FetchProcessorTypes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor.js new file mode 100644 index 00000000000..91913575c66 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1_generated_DocumentProcessorService_GetProcessor_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor resource name. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callGetProcessor() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await documentaiClient.getProcessor(request); + console.log(response); + } + + callGetProcessor(); + // [END documentai_v1_generated_DocumentProcessorService_GetProcessor_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor_version.js new file mode 100644 index 00000000000..31bcc81a04f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor_version.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1_generated_DocumentProcessorService_GetProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor resource name. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callGetProcessorVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await documentaiClient.getProcessorVersion(request); + console.log(response); + } + + callGetProcessorVersion(); + // [END documentai_v1_generated_DocumentProcessorService_GetProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_types.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_types.js new file mode 100644 index 00000000000..a900fd1e249 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_types.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START documentai_v1_generated_DocumentProcessorService_ListProcessorTypes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + */ + // const parent = 'abc123' + /** + * The maximum number of processor types to return. + * If unspecified, at most 100 processor types will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + */ + // const pageSize = 1234 + /** + * Used to retrieve the next page of results, empty if at the end of the list. + */ + // const pageToken = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callListProcessorTypes() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await documentaiClient.listProcessorTypesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProcessorTypes(); + // [END documentai_v1_generated_DocumentProcessorService_ListProcessorTypes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_versions.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_versions.js new file mode 100644 index 00000000000..490c0fb5038 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_versions.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START documentai_v1_generated_DocumentProcessorService_ListProcessorVersions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent (project, location and processor) to list all versions. + * Format: `projects/{project}/locations/{location}/processors/{processor}` + */ + // const parent = 'abc123' + /** + * The maximum number of processor versions to return. + * If unspecified, at most 10 processor versions will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + */ + // const pageSize = 1234 + /** + * We will return the processor versions sorted by creation time. The page + * token will point to the next processor version. + */ + // const pageToken = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callListProcessorVersions() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await documentaiClient.listProcessorVersionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProcessorVersions(); + // [END documentai_v1_generated_DocumentProcessorService_ListProcessorVersions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processors.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processors.js new file mode 100644 index 00000000000..62b63c5ce60 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processors.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START documentai_v1_generated_DocumentProcessorService_ListProcessors_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent (project and location) which owns this collection of Processors. + * Format: `projects/{project}/locations/{location}` + */ + // const parent = 'abc123' + /** + * 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. + */ + // const pageSize = 1234 + /** + * We will return the processors sorted by creation time. The page token + * will point to the next processor. + */ + // const pageToken = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callListProcessors() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await documentaiClient.listProcessorsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProcessors(); + // [END documentai_v1_generated_DocumentProcessorService_ListProcessors_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.process_document.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.process_document.js new file mode 100644 index 00000000000..dfcb92d5a7d --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.process_document.js @@ -0,0 +1,85 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1_generated_DocumentProcessorService_ProcessDocument_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * An inline document proto. + */ + // const inlineDocument = {} + /** + * A raw document content (bytes). + */ + // const rawDocument = {} + /** + * Required. The resource name of the Processor google.cloud.documentai.v1.Processor or + * ProcessorVersion google.cloud.documentai.v1.ProcessorVersion + * to use for processing. If a Processor google.cloud.documentai.v1.Processor is specified, the server will use + * its default version google.cloud.documentai.v1.Processor.default_processor_version. Format: + * `projects/{project}/locations/{location}/processors/{processor}`, or + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + */ + // const name = 'abc123' + /** + * Whether Human Review feature should be skipped for this request. Default to + * false. + */ + // const skipHumanReview = true + /** + * Specifies which fields to include in ProcessResponse's document. + * Only supports top level document and pages field so it must be in the form + * of `{document_field_name}` or `pages.{page_field_name}`. + */ + // const fieldMask = {} + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callProcessDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await documentaiClient.processDocument(request); + console.log(response); + } + + callProcessDocument(); + // [END documentai_v1_generated_DocumentProcessorService_ProcessDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.review_document.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.review_document.js new file mode 100644 index 00000000000..583b5a9b150 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.review_document.js @@ -0,0 +1,79 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(humanReviewConfig) { + // [START documentai_v1_generated_DocumentProcessorService_ReviewDocument_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * An inline document proto. + */ + // const inlineDocument = {} + /** + * Required. The resource name of the HumanReviewConfig that the document will be + * reviewed with. + */ + // const humanReviewConfig = 'abc123' + /** + * Whether the validation should be performed on the ad-hoc review request. + */ + // const enableSchemaValidation = true + /** + * The priority of the human review task. + */ + // const priority = {} + /** + * The document schema of the human review task. + */ + // const documentSchema = {} + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callReviewDocument() { + // Construct request + const request = { + humanReviewConfig, + }; + + // Run request + const [operation] = await documentaiClient.reviewDocument(request); + const [response] = await operation.promise(); + console.log(response); + } + + callReviewDocument(); + // [END documentai_v1_generated_DocumentProcessorService_ReviewDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.set_default_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.set_default_processor_version.js new file mode 100644 index 00000000000..64556b986f5 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.set_default_processor_version.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(processor, defaultProcessorVersion) { + // [START documentai_v1_generated_DocumentProcessorService_SetDefaultProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Processor google.cloud.documentai.v1.Processor to change default version. + */ + // const processor = 'abc123' + /** + * Required. The resource name of child ProcessorVersion google.cloud.documentai.v1.ProcessorVersion to use as default. + * Format: + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` + */ + // const defaultProcessorVersion = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callSetDefaultProcessorVersion() { + // Construct request + const request = { + processor, + defaultProcessorVersion, + }; + + // Run request + const [operation] = await documentaiClient.setDefaultProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetDefaultProcessorVersion(); + // [END documentai_v1_generated_DocumentProcessorService_SetDefaultProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.undeploy_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.undeploy_processor_version.js new file mode 100644 index 00000000000..5c84587ee7b --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.undeploy_processor_version.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1_generated_DocumentProcessorService_UndeployProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor version resource name to be undeployed. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callUndeployProcessorVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.undeployProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUndeployProcessorVersion(); + // [END documentai_v1_generated_DocumentProcessorService_UndeployProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/snippet_metadata.google.cloud.documentai.v1.json b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/snippet_metadata.google.cloud.documentai.v1.json new file mode 100644 index 00000000000..2293cffa613 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/snippet_metadata.google.cloud.documentai.v1.json @@ -0,0 +1,771 @@ +{ + "clientLibrary": { + "name": "nodejs-documentai", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.documentai.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_ProcessDocument_async", + "title": "DocumentProcessorService processDocument Sample", + "origin": "API_DEFINITION", + "description": " Processes a single document.", + "canonical": true, + "file": "document_processor_service.process_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ProcessDocument", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument", + "async": true, + "parameters": [ + { + "name": "inline_document", + "type": ".google.cloud.documentai.v1.Document" + }, + { + "name": "raw_document", + "type": ".google.cloud.documentai.v1.RawDocument" + }, + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "skip_human_review", + "type": "TYPE_BOOL" + }, + { + "name": "field_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.documentai.v1.ProcessResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ProcessDocument", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async", + "title": "DocumentProcessorService batchProcessDocuments Sample", + "origin": "API_DEFINITION", + "description": " LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.", + "canonical": true, + "file": "document_processor_service.batch_process_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchProcessDocuments", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "input_documents", + "type": ".google.cloud.documentai.v1.BatchDocumentsInputConfig" + }, + { + "name": "document_output_config", + "type": ".google.cloud.documentai.v1.DocumentOutputConfig" + }, + { + "name": "skip_human_review", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "BatchProcessDocuments", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_FetchProcessorTypes_async", + "title": "DocumentProcessorService fetchProcessorTypes Sample", + "origin": "API_DEFINITION", + "description": " Fetches processor types. Note that we do not use ListProcessorTypes here because it is not paginated.", + "canonical": true, + "file": "document_processor_service.fetch_processor_types.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "FetchProcessorTypes", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.FetchProcessorTypes", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1.FetchProcessorTypesResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "FetchProcessorTypes", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.FetchProcessorTypes", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_ListProcessorTypes_async", + "title": "DocumentProcessorService listProcessorTypes Sample", + "origin": "API_DEFINITION", + "description": " Lists the processor types that exist.", + "canonical": true, + "file": "document_processor_service.list_processor_types.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProcessorTypes", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessorTypes", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1.ListProcessorTypesResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ListProcessorTypes", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessorTypes", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_ListProcessors_async", + "title": "DocumentProcessorService listProcessors Sample", + "origin": "API_DEFINITION", + "description": " Lists all processors which belong to this project.", + "canonical": true, + "file": "document_processor_service.list_processors.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProcessors", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessors", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1.ListProcessorsResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ListProcessors", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessors", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_GetProcessor_async", + "title": "DocumentProcessorService getProcessor Sample", + "origin": "API_DEFINITION", + "description": " Gets a processor detail.", + "canonical": true, + "file": "document_processor_service.get_processor.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProcessor", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.GetProcessor", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1.Processor", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "GetProcessor", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.GetProcessor", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_GetProcessorVersion_async", + "title": "DocumentProcessorService getProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Gets a processor version detail.", + "canonical": true, + "file": "document_processor_service.get_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProcessorVersion", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.GetProcessorVersion", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1.ProcessorVersion", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "GetProcessorVersion", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.GetProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_ListProcessorVersions_async", + "title": "DocumentProcessorService listProcessorVersions Sample", + "origin": "API_DEFINITION", + "description": " Lists all versions of a processor.", + "canonical": true, + "file": "document_processor_service.list_processor_versions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProcessorVersions", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessorVersions", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1.ListProcessorVersionsResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ListProcessorVersions", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessorVersions", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_DeleteProcessorVersion_async", + "title": "DocumentProcessorService deleteProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Deletes the processor version, all artifacts under the processor version will be deleted.", + "canonical": true, + "file": "document_processor_service.delete_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProcessorVersion", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeleteProcessorVersion", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "DeleteProcessorVersion", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeleteProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_DeployProcessorVersion_async", + "title": "DocumentProcessorService deployProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Deploys the processor version.", + "canonical": true, + "file": "document_processor_service.deploy_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeployProcessorVersion", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeployProcessorVersion", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "DeployProcessorVersion", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeployProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_UndeployProcessorVersion_async", + "title": "DocumentProcessorService undeployProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Undeploys the processor version.", + "canonical": true, + "file": "document_processor_service.undeploy_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UndeployProcessorVersion", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.UndeployProcessorVersion", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "UndeployProcessorVersion", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.UndeployProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_CreateProcessor_async", + "title": "DocumentProcessorService createProcessor Sample", + "origin": "API_DEFINITION", + "description": " Creates a processor from the type processor that the user chose. The processor will be at \"ENABLED\" state by default after its creation.", + "canonical": true, + "file": "document_processor_service.create_processor.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProcessor", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.CreateProcessor", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "processor", + "type": ".google.cloud.documentai.v1.Processor" + } + ], + "resultType": ".google.cloud.documentai.v1.Processor", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "CreateProcessor", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.CreateProcessor", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_DeleteProcessor_async", + "title": "DocumentProcessorService deleteProcessor Sample", + "origin": "API_DEFINITION", + "description": " Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.", + "canonical": true, + "file": "document_processor_service.delete_processor.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProcessor", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeleteProcessor", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "DeleteProcessor", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeleteProcessor", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_EnableProcessor_async", + "title": "DocumentProcessorService enableProcessor Sample", + "origin": "API_DEFINITION", + "description": " Enables a processor", + "canonical": true, + "file": "document_processor_service.enable_processor.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "EnableProcessor", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.EnableProcessor", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "EnableProcessor", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.EnableProcessor", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_DisableProcessor_async", + "title": "DocumentProcessorService disableProcessor Sample", + "origin": "API_DEFINITION", + "description": " Disables a processor", + "canonical": true, + "file": "document_processor_service.disable_processor.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DisableProcessor", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DisableProcessor", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "DisableProcessor", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DisableProcessor", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_SetDefaultProcessorVersion_async", + "title": "DocumentProcessorService setDefaultProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Set the default (active) version of a [Processor][google.cloud.documentai.v1.Processor] that will be used in [ProcessDocument][google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument] and [BatchProcessDocuments][google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments].", + "canonical": true, + "file": "document_processor_service.set_default_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultProcessorVersion", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.SetDefaultProcessorVersion", + "async": true, + "parameters": [ + { + "name": "processor", + "type": "TYPE_STRING" + }, + { + "name": "default_processor_version", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "SetDefaultProcessorVersion", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.SetDefaultProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1_generated_DocumentProcessorService_ReviewDocument_async", + "title": "DocumentProcessorService reviewDocument Sample", + "origin": "API_DEFINITION", + "description": " Send a document for Human Review. The input document should be processed by the specified processor.", + "canonical": true, + "file": "document_processor_service.review_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReviewDocument", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ReviewDocument", + "async": true, + "parameters": [ + { + "name": "inline_document", + "type": ".google.cloud.documentai.v1.Document" + }, + { + "name": "human_review_config", + "type": "TYPE_STRING" + }, + { + "name": "enable_schema_validation", + "type": "TYPE_BOOL" + }, + { + "name": "priority", + "type": ".google.cloud.documentai.v1.ReviewDocumentRequest.Priority" + }, + { + "name": "document_schema", + "type": ".google.cloud.documentai.v1.DocumentSchema" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ReviewDocument", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ReviewDocument", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1.DocumentProcessorService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1/src/index.ts new file mode 100644 index 00000000000..a59bbb62811 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts new file mode 100644 index 00000000000..a2417e84836 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts @@ -0,0 +1,2760 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/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'; +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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new DocumentProcessorServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + processorVersionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}' + ), + 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 = { + listProcessorTypes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processorTypes'), + listProcessors: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processors'), + listProcessorVersions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processorVersions') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',additional_bindings: [{get: '/uiv1beta3/{name=projects/*/locations/*}',}], + },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',additional_bindings: [{get: '/uiv1beta3/{name=projects/*}/locations',}], + },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',additional_bindings: [{post: '/uiv1beta3/{name=projects/*/locations/*/operations/*}:cancel',}], + },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/uiv1beta3/{name=projects/*/locations/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*/operations}',additional_bindings: [{get: '/uiv1beta3/{name=projects/*/locations/*/operations}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 deleteProcessorVersionResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.DeleteProcessorVersionMetadata') as gax.protobuf.Type; + const deployProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.DeployProcessorVersionResponse') as gax.protobuf.Type; + const deployProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.DeployProcessorVersionMetadata') as gax.protobuf.Type; + const undeployProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.UndeployProcessorVersionResponse') as gax.protobuf.Type; + const undeployProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.UndeployProcessorVersionMetadata') as gax.protobuf.Type; + const deleteProcessorResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteProcessorMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.DeleteProcessorMetadata') as gax.protobuf.Type; + const enableProcessorResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.EnableProcessorResponse') as gax.protobuf.Type; + const enableProcessorMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.EnableProcessorMetadata') as gax.protobuf.Type; + const disableProcessorResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.DisableProcessorResponse') as gax.protobuf.Type; + const disableProcessorMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.DisableProcessorMetadata') as gax.protobuf.Type; + const setDefaultProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.SetDefaultProcessorVersionResponse') as gax.protobuf.Type; + const setDefaultProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1.SetDefaultProcessorVersionMetadata') 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)), + deleteProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteProcessorVersionResponse.decode.bind(deleteProcessorVersionResponse), + deleteProcessorVersionMetadata.decode.bind(deleteProcessorVersionMetadata)), + deployProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deployProcessorVersionResponse.decode.bind(deployProcessorVersionResponse), + deployProcessorVersionMetadata.decode.bind(deployProcessorVersionMetadata)), + undeployProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + undeployProcessorVersionResponse.decode.bind(undeployProcessorVersionResponse), + undeployProcessorVersionMetadata.decode.bind(undeployProcessorVersionMetadata)), + 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)), + setDefaultProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setDefaultProcessorVersionResponse.decode.bind(setDefaultProcessorVersionResponse), + setDefaultProcessorVersionMetadata.decode.bind(setDefaultProcessorVersionMetadata)), + 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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', 'fetchProcessorTypes', 'listProcessorTypes', 'listProcessors', 'getProcessor', 'getProcessorVersion', 'listProcessorVersions', 'deleteProcessorVersion', 'deployProcessorVersion', 'undeployProcessorVersion', 'createProcessor', 'deleteProcessor', 'enableProcessor', 'disableProcessor', 'setDefaultProcessorVersion', '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._opts.fallback + ); + + 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 -- + // ------------------- +/** + * 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 resource name of the {@link google.cloud.documentai.v1.Processor|Processor} or + * {@link google.cloud.documentai.v1.ProcessorVersion|ProcessorVersion} + * to use for processing. If a {@link google.cloud.documentai.v1.Processor|Processor} is specified, the server will use + * its {@link google.cloud.documentai.v1.Processor.default_processor_version|default version}. Format: + * `projects/{project}/locations/{location}/processors/{processor}`, or + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @param {boolean} request.skipHumanReview + * Whether Human Review feature should be skipped for this request. Default to + * false. + * @param {google.protobuf.FieldMask} request.fieldMask + * Specifies which fields to include in ProcessResponse's document. + * Only supports top level document and pages field so it must be in the form + * of `{document_field_name}` or `pages.{page_field_name}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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 include:samples/generated/v1/document_processor_service.process_document.js + * region_tag:documentai_v1_generated_DocumentProcessorService_ProcessDocument_async + */ + 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; + 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.processDocument(request, options, callback); + } +/** + * Fetches processor types. Note that we do not use ListProcessorTypes here + * because it is not paginated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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.v1.FetchProcessorTypesResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.fetch_processor_types.js + * region_tag:documentai_v1_generated_DocumentProcessorService_FetchProcessorTypes_async + */ + fetchProcessorTypes( + request?: protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest|undefined, {}|undefined + ]>; + fetchProcessorTypes( + request: protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest|null|undefined, + {}|null|undefined>): void; + fetchProcessorTypes( + request: protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest, + callback: Callback< + protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest|null|undefined, + {}|null|undefined>): void; + fetchProcessorTypes( + request?: protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, + protos.google.cloud.documentai.v1.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.fetchProcessorTypes(request, options, callback); + } +/** + * Gets a processor detail. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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.v1.Processor}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.get_processor.js + * region_tag:documentai_v1_generated_DocumentProcessorService_GetProcessor_async + */ + getProcessor( + request?: protos.google.cloud.documentai.v1.IGetProcessorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.IGetProcessorRequest|undefined, {}|undefined + ]>; + getProcessor( + request: protos.google.cloud.documentai.v1.IGetProcessorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.IGetProcessorRequest|null|undefined, + {}|null|undefined>): void; + getProcessor( + request: protos.google.cloud.documentai.v1.IGetProcessorRequest, + callback: Callback< + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.IGetProcessorRequest|null|undefined, + {}|null|undefined>): void; + getProcessor( + request?: protos.google.cloud.documentai.v1.IGetProcessorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.IGetProcessorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.IGetProcessorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.IGetProcessorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProcessor(request, options, callback); + } +/** + * Gets a processor version detail. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProcessorVersion]{@link google.cloud.documentai.v1.ProcessorVersion}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.get_processor_version.js + * region_tag:documentai_v1_generated_DocumentProcessorService_GetProcessorVersion_async + */ + getProcessorVersion( + request?: protos.google.cloud.documentai.v1.IGetProcessorVersionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1.IProcessorVersion, + protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|undefined, {}|undefined + ]>; + getProcessorVersion( + request: protos.google.cloud.documentai.v1.IGetProcessorVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1.IProcessorVersion, + protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|null|undefined, + {}|null|undefined>): void; + getProcessorVersion( + request: protos.google.cloud.documentai.v1.IGetProcessorVersionRequest, + callback: Callback< + protos.google.cloud.documentai.v1.IProcessorVersion, + protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|null|undefined, + {}|null|undefined>): void; + getProcessorVersion( + request?: protos.google.cloud.documentai.v1.IGetProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1.IProcessorVersion, + protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1.IProcessorVersion, + protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1.IProcessorVersion, + protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProcessorVersion(request, options, callback); + } +/** + * 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.v1.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.v1.Processor}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.create_processor.js + * region_tag:documentai_v1_generated_DocumentProcessorService_CreateProcessor_async + */ + createProcessor( + request?: protos.google.cloud.documentai.v1.ICreateProcessorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.ICreateProcessorRequest|undefined, {}|undefined + ]>; + createProcessor( + request: protos.google.cloud.documentai.v1.ICreateProcessorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.ICreateProcessorRequest|null|undefined, + {}|null|undefined>): void; + createProcessor( + request: protos.google.cloud.documentai.v1.ICreateProcessorRequest, + callback: Callback< + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.ICreateProcessorRequest|null|undefined, + {}|null|undefined>): void; + createProcessor( + request?: protos.google.cloud.documentai.v1.ICreateProcessorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.ICreateProcessorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.ICreateProcessorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1.IProcessor, + protos.google.cloud.documentai.v1.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProcessor(request, options, callback); + } + +/** + * 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 resource name of {@link google.cloud.documentai.v1.Processor|Processor} or + * {@link google.cloud.documentai.v1.ProcessorVersion|ProcessorVersion}. + * Format: `projects/{project}/locations/{location}/processors/{processor}`, + * or + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @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 include:samples/generated/v1/document_processor_service.batch_process_documents.js + * region_tag:documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async + */ + 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; + 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' + ] = this._gaxModule.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 include:samples/generated/v1/document_processor_service.batch_process_documents.js + * region_tag:documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async + */ + async checkBatchProcessDocumentsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes the processor version, all artifacts under the processor version + * will be deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor version 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 include:samples/generated/v1/document_processor_service.delete_processor_version.js + * region_tag:documentai_v1_generated_DocumentProcessorService_DeleteProcessorVersion_async + */ + deleteProcessorVersion( + request?: protos.google.cloud.documentai.v1.IDeleteProcessorVersionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteProcessorVersion( + request: protos.google.cloud.documentai.v1.IDeleteProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProcessorVersion( + request: protos.google.cloud.documentai.v1.IDeleteProcessorVersionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProcessorVersion( + request?: protos.google.cloud.documentai.v1.IDeleteProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProcessorVersion(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.delete_processor_version.js + * region_tag:documentai_v1_generated_DocumentProcessorService_DeleteProcessorVersion_async + */ + async checkDeleteProcessorVersionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deploys the processor version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor version resource name to be deployed. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.deploy_processor_version.js + * region_tag:documentai_v1_generated_DocumentProcessorService_DeployProcessorVersion_async + */ + deployProcessorVersion( + request?: protos.google.cloud.documentai.v1.IDeployProcessorVersionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deployProcessorVersion( + request: protos.google.cloud.documentai.v1.IDeployProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deployProcessorVersion( + request: protos.google.cloud.documentai.v1.IDeployProcessorVersionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deployProcessorVersion( + request?: protos.google.cloud.documentai.v1.IDeployProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deployProcessorVersion(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deployProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.deploy_processor_version.js + * region_tag:documentai_v1_generated_DocumentProcessorService_DeployProcessorVersion_async + */ + async checkDeployProcessorVersionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deployProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Undeploys the processor version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor version resource name to be undeployed. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.undeploy_processor_version.js + * region_tag:documentai_v1_generated_DocumentProcessorService_UndeployProcessorVersion_async + */ + undeployProcessorVersion( + request?: protos.google.cloud.documentai.v1.IUndeployProcessorVersionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + undeployProcessorVersion( + request: protos.google.cloud.documentai.v1.IUndeployProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeployProcessorVersion( + request: protos.google.cloud.documentai.v1.IUndeployProcessorVersionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeployProcessorVersion( + request?: protos.google.cloud.documentai.v1.IUndeployProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.undeployProcessorVersion(request, options, callback); + } +/** + * Check the status of the long running operation returned by `undeployProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.undeploy_processor_version.js + * region_tag:documentai_v1_generated_DocumentProcessorService_UndeployProcessorVersion_async + */ + async checkUndeployProcessorVersionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.undeployProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * 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 include:samples/generated/v1/document_processor_service.delete_processor.js + * region_tag:documentai_v1_generated_DocumentProcessorService_DeleteProcessor_async + */ + deleteProcessor( + request?: protos.google.cloud.documentai.v1.IDeleteProcessorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteProcessor( + request: protos.google.cloud.documentai.v1.IDeleteProcessorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProcessor( + request: protos.google.cloud.documentai.v1.IDeleteProcessorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProcessor( + request?: protos.google.cloud.documentai.v1.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' + ] = this._gaxModule.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 include:samples/generated/v1/document_processor_service.delete_processor.js + * region_tag:documentai_v1_generated_DocumentProcessorService_DeleteProcessor_async + */ + async checkDeleteProcessorProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteProcessor, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * 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 include:samples/generated/v1/document_processor_service.enable_processor.js + * region_tag:documentai_v1_generated_DocumentProcessorService_EnableProcessor_async + */ + enableProcessor( + request?: protos.google.cloud.documentai.v1.IEnableProcessorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + enableProcessor( + request: protos.google.cloud.documentai.v1.IEnableProcessorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + enableProcessor( + request: protos.google.cloud.documentai.v1.IEnableProcessorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + enableProcessor( + request?: protos.google.cloud.documentai.v1.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' + ] = this._gaxModule.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 include:samples/generated/v1/document_processor_service.enable_processor.js + * region_tag:documentai_v1_generated_DocumentProcessorService_EnableProcessor_async + */ + async checkEnableProcessorProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.enableProcessor, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * 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 include:samples/generated/v1/document_processor_service.disable_processor.js + * region_tag:documentai_v1_generated_DocumentProcessorService_DisableProcessor_async + */ + disableProcessor( + request?: protos.google.cloud.documentai.v1.IDisableProcessorRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + disableProcessor( + request: protos.google.cloud.documentai.v1.IDisableProcessorRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + disableProcessor( + request: protos.google.cloud.documentai.v1.IDisableProcessorRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + disableProcessor( + request?: protos.google.cloud.documentai.v1.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' + ] = this._gaxModule.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 include:samples/generated/v1/document_processor_service.disable_processor.js + * region_tag:documentai_v1_generated_DocumentProcessorService_DisableProcessor_async + */ + async checkDisableProcessorProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.disableProcessor, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Set the default (active) version of a {@link google.cloud.documentai.v1.Processor|Processor} that will be used in + * {@link google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument|ProcessDocument} and + * {@link google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments|BatchProcessDocuments}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.processor + * Required. The resource name of the {@link google.cloud.documentai.v1.Processor|Processor} to change default version. + * @param {string} request.defaultProcessorVersion + * Required. The resource name of child {@link google.cloud.documentai.v1.ProcessorVersion|ProcessorVersion} to use as default. + * Format: + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.set_default_processor_version.js + * region_tag:documentai_v1_generated_DocumentProcessorService_SetDefaultProcessorVersion_async + */ + setDefaultProcessorVersion( + request?: protos.google.cloud.documentai.v1.ISetDefaultProcessorVersionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setDefaultProcessorVersion( + request: protos.google.cloud.documentai.v1.ISetDefaultProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setDefaultProcessorVersion( + request: protos.google.cloud.documentai.v1.ISetDefaultProcessorVersionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setDefaultProcessorVersion( + request?: protos.google.cloud.documentai.v1.ISetDefaultProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'processor': request.processor ?? '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultProcessorVersion(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setDefaultProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.set_default_processor_version.js + * region_tag:documentai_v1_generated_DocumentProcessorService_SetDefaultProcessorVersion_async + */ + async checkSetDefaultProcessorVersionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.setDefaultProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * 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 {google.cloud.documentai.v1.DocumentSchema} request.documentSchema + * The document schema 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 include:samples/generated/v1/document_processor_service.review_document.js + * region_tag:documentai_v1_generated_DocumentProcessorService_ReviewDocument_async + */ + 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; + 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' + ] = this._gaxModule.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 include:samples/generated/v1/document_processor_service.review_document.js + * region_tag:documentai_v1_generated_DocumentProcessorService_ReviewDocument_async + */ + async checkReviewDocumentProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.reviewDocument, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists the processor types that exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + * @param {number} request.pageSize + * The maximum number of processor types to return. + * If unspecified, at most 100 processor types will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + * @param {string} request.pageToken + * Used to retrieve the next page of results, empty if at the end of the list. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ProcessorType]{@link google.cloud.documentai.v1.ProcessorType}. + * 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 `listProcessorTypesAsync()` + * 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. + */ + listProcessorTypes( + request?: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1.IProcessorType[], + protos.google.cloud.documentai.v1.IListProcessorTypesRequest|null, + protos.google.cloud.documentai.v1.IListProcessorTypesResponse + ]>; + listProcessorTypes( + request: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorTypesRequest, + protos.google.cloud.documentai.v1.IListProcessorTypesResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessorType>): void; + listProcessorTypes( + request: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, + callback: PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorTypesRequest, + protos.google.cloud.documentai.v1.IListProcessorTypesResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessorType>): void; + listProcessorTypes( + request?: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorTypesRequest, + protos.google.cloud.documentai.v1.IListProcessorTypesResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessorType>, + callback?: PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorTypesRequest, + protos.google.cloud.documentai.v1.IListProcessorTypesResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessorType>): + Promise<[ + protos.google.cloud.documentai.v1.IProcessorType[], + protos.google.cloud.documentai.v1.IListProcessorTypesRequest|null, + protos.google.cloud.documentai.v1.IListProcessorTypesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProcessorTypes(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 location of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + * @param {number} request.pageSize + * The maximum number of processor types to return. + * If unspecified, at most 100 processor types will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + * @param {string} request.pageToken + * Used to retrieve the next page of results, empty if at the end of the list. + * @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 [ProcessorType]{@link google.cloud.documentai.v1.ProcessorType} 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 `listProcessorTypesAsync()` + * 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. + */ + listProcessorTypesStream( + request?: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessorTypes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessorTypes.createStream( + this.innerApiCalls.listProcessorTypes as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProcessorTypes`, 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 location of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + * @param {number} request.pageSize + * The maximum number of processor types to return. + * If unspecified, at most 100 processor types will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + * @param {string} request.pageToken + * Used to retrieve the next page of results, empty if at the end of the list. + * @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 + * [ProcessorType]{@link google.cloud.documentai.v1.ProcessorType}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.list_processor_types.js + * region_tag:documentai_v1_generated_DocumentProcessorService_ListProcessorTypes_async + */ + listProcessorTypesAsync( + request?: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessorTypes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessorTypes.asyncIterate( + this.innerApiCalls['listProcessorTypes'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * 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.v1.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.v1.IListProcessorsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1.IProcessor[], + protos.google.cloud.documentai.v1.IListProcessorsRequest|null, + protos.google.cloud.documentai.v1.IListProcessorsResponse + ]>; + listProcessors( + request: protos.google.cloud.documentai.v1.IListProcessorsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorsRequest, + protos.google.cloud.documentai.v1.IListProcessorsResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessor>): void; + listProcessors( + request: protos.google.cloud.documentai.v1.IListProcessorsRequest, + callback: PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorsRequest, + protos.google.cloud.documentai.v1.IListProcessorsResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessor>): void; + listProcessors( + request?: protos.google.cloud.documentai.v1.IListProcessorsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorsRequest, + protos.google.cloud.documentai.v1.IListProcessorsResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessor>, + callback?: PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorsRequest, + protos.google.cloud.documentai.v1.IListProcessorsResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessor>): + Promise<[ + protos.google.cloud.documentai.v1.IProcessor[], + protos.google.cloud.documentai.v1.IListProcessorsRequest|null, + protos.google.cloud.documentai.v1.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' + ] = this._gaxModule.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.v1.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.v1.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessors']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessors.createStream( + this.innerApiCalls.listProcessors as 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.v1.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 include:samples/generated/v1/document_processor_service.list_processors.js + * region_tag:documentai_v1_generated_DocumentProcessorService_ListProcessors_async + */ + listProcessorsAsync( + request?: protos.google.cloud.documentai.v1.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessors']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessors.asyncIterate( + this.innerApiCalls['listProcessors'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all versions of a processor. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project, location and processor) to list all versions. + * Format: `projects/{project}/locations/{location}/processors/{processor}` + * @param {number} request.pageSize + * The maximum number of processor versions to return. + * If unspecified, at most 10 processor versions will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * We will return the processor versions sorted by creation time. The page + * token will point to the next processor version. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ProcessorVersion]{@link google.cloud.documentai.v1.ProcessorVersion}. + * 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 `listProcessorVersionsAsync()` + * 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. + */ + listProcessorVersions( + request?: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1.IProcessorVersion[], + protos.google.cloud.documentai.v1.IListProcessorVersionsRequest|null, + protos.google.cloud.documentai.v1.IListProcessorVersionsResponse + ]>; + listProcessorVersions( + request: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, + protos.google.cloud.documentai.v1.IListProcessorVersionsResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessorVersion>): void; + listProcessorVersions( + request: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, + protos.google.cloud.documentai.v1.IListProcessorVersionsResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessorVersion>): void; + listProcessorVersions( + request?: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, + protos.google.cloud.documentai.v1.IListProcessorVersionsResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessorVersion>, + callback?: PaginationCallback< + protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, + protos.google.cloud.documentai.v1.IListProcessorVersionsResponse|null|undefined, + protos.google.cloud.documentai.v1.IProcessorVersion>): + Promise<[ + protos.google.cloud.documentai.v1.IProcessorVersion[], + protos.google.cloud.documentai.v1.IListProcessorVersionsRequest|null, + protos.google.cloud.documentai.v1.IListProcessorVersionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProcessorVersions(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, location and processor) to list all versions. + * Format: `projects/{project}/locations/{location}/processors/{processor}` + * @param {number} request.pageSize + * The maximum number of processor versions to return. + * If unspecified, at most 10 processor versions will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * We will return the processor versions sorted by creation time. The page + * token will point to the next processor version. + * @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 [ProcessorVersion]{@link google.cloud.documentai.v1.ProcessorVersion} 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 `listProcessorVersionsAsync()` + * 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. + */ + listProcessorVersionsStream( + request?: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessorVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessorVersions.createStream( + this.innerApiCalls.listProcessorVersions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProcessorVersions`, 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, location and processor) to list all versions. + * Format: `projects/{project}/locations/{location}/processors/{processor}` + * @param {number} request.pageSize + * The maximum number of processor versions to return. + * If unspecified, at most 10 processor versions will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * We will return the processor versions sorted by creation time. The page + * token will point to the next processor version. + * @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 + * [ProcessorVersion]{@link google.cloud.documentai.v1.ProcessorVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/document_processor_service.list_processor_versions.js + * region_tag:documentai_v1_generated_DocumentProcessorService_ListProcessorVersions_async + */ + listProcessorVersionsAsync( + request?: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessorVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessorVersions.asyncIterate( + this.innerApiCalls['listProcessorVersions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 processorVersion resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} processor + * @param {string} processor_version + * @returns {string} Resource name string. + */ + processorVersionPath(project:string,location:string,processor:string,processorVersion:string) { + return this.pathTemplates.processorVersionPathTemplate.render({ + project: project, + location: location, + processor: processor, + processor_version: processorVersion, + }); + } + + /** + * Parse the project from ProcessorVersion resource. + * + * @param {string} processorVersionName + * A fully-qualified path representing ProcessorVersion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProcessorVersionName(processorVersionName: string) { + return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).project; + } + + /** + * Parse the location from ProcessorVersion resource. + * + * @param {string} processorVersionName + * A fully-qualified path representing ProcessorVersion resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProcessorVersionName(processorVersionName: string) { + return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).location; + } + + /** + * Parse the processor from ProcessorVersion resource. + * + * @param {string} processorVersionName + * A fully-qualified path representing ProcessorVersion resource. + * @returns {string} A string representing the processor. + */ + matchProcessorFromProcessorVersionName(processorVersionName: string) { + return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).processor; + } + + /** + * Parse the processor_version from ProcessorVersion resource. + * + * @param {string} processorVersionName + * A fully-qualified path representing ProcessorVersion resource. + * @returns {string} A string representing the processor_version. + */ + matchProcessorVersionFromProcessorVersionName(processorVersionName: string) { + return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).processor_version; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.documentProcessorServiceStub && !this._terminated) { + return this.documentProcessorServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client_config.json b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client_config.json new file mode 100644 index 00000000000..d5b952a9834 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client_config.json @@ -0,0 +1,97 @@ +{ + "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" + }, + "FetchProcessorTypes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProcessorTypes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProcessors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetProcessor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProcessorVersions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeployProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UndeployProcessorVersion": { + "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" + }, + "SetDefaultProcessorVersion": { + "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/google-cloud-documentai/v1/src/v1/document_processor_service_proto_list.json b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_proto_list.json new file mode 100644 index 00000000000..a19f0a8b0ca --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_proto_list.json @@ -0,0 +1,11 @@ +[ + "../../protos/google/cloud/documentai/v1/barcode.proto", + "../../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/document_schema.proto", + "../../protos/google/cloud/documentai/v1/geometry.proto", + "../../protos/google/cloud/documentai/v1/operation_metadata.proto", + "../../protos/google/cloud/documentai/v1/processor.proto", + "../../protos/google/cloud/documentai/v1/processor_type.proto" +] diff --git a/owl-bot-staging/google-cloud-documentai/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-documentai/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..0c0e9a859b2 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/src/v1/gapic_metadata.json @@ -0,0 +1,205 @@ +{ + "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" + ] + }, + "FetchProcessorTypes": { + "methods": [ + "fetchProcessorTypes" + ] + }, + "GetProcessor": { + "methods": [ + "getProcessor" + ] + }, + "GetProcessorVersion": { + "methods": [ + "getProcessorVersion" + ] + }, + "CreateProcessor": { + "methods": [ + "createProcessor" + ] + }, + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + }, + "DeleteProcessorVersion": { + "methods": [ + "deleteProcessorVersion" + ] + }, + "DeployProcessorVersion": { + "methods": [ + "deployProcessorVersion" + ] + }, + "UndeployProcessorVersion": { + "methods": [ + "undeployProcessorVersion" + ] + }, + "DeleteProcessor": { + "methods": [ + "deleteProcessor" + ] + }, + "EnableProcessor": { + "methods": [ + "enableProcessor" + ] + }, + "DisableProcessor": { + "methods": [ + "disableProcessor" + ] + }, + "SetDefaultProcessorVersion": { + "methods": [ + "setDefaultProcessorVersion" + ] + }, + "ReviewDocument": { + "methods": [ + "reviewDocument" + ] + }, + "ListProcessorTypes": { + "methods": [ + "listProcessorTypes", + "listProcessorTypesStream", + "listProcessorTypesAsync" + ] + }, + "ListProcessors": { + "methods": [ + "listProcessors", + "listProcessorsStream", + "listProcessorsAsync" + ] + }, + "ListProcessorVersions": { + "methods": [ + "listProcessorVersions", + "listProcessorVersionsStream", + "listProcessorVersionsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentProcessorServiceClient", + "rpcs": { + "ProcessDocument": { + "methods": [ + "processDocument" + ] + }, + "FetchProcessorTypes": { + "methods": [ + "fetchProcessorTypes" + ] + }, + "GetProcessor": { + "methods": [ + "getProcessor" + ] + }, + "GetProcessorVersion": { + "methods": [ + "getProcessorVersion" + ] + }, + "CreateProcessor": { + "methods": [ + "createProcessor" + ] + }, + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + }, + "DeleteProcessorVersion": { + "methods": [ + "deleteProcessorVersion" + ] + }, + "DeployProcessorVersion": { + "methods": [ + "deployProcessorVersion" + ] + }, + "UndeployProcessorVersion": { + "methods": [ + "undeployProcessorVersion" + ] + }, + "DeleteProcessor": { + "methods": [ + "deleteProcessor" + ] + }, + "EnableProcessor": { + "methods": [ + "enableProcessor" + ] + }, + "DisableProcessor": { + "methods": [ + "disableProcessor" + ] + }, + "SetDefaultProcessorVersion": { + "methods": [ + "setDefaultProcessorVersion" + ] + }, + "ReviewDocument": { + "methods": [ + "reviewDocument" + ] + }, + "ListProcessorTypes": { + "methods": [ + "listProcessorTypes", + "listProcessorTypesStream", + "listProcessorTypesAsync" + ] + }, + "ListProcessors": { + "methods": [ + "listProcessors", + "listProcessorsStream", + "listProcessorsAsync" + ] + }, + "ListProcessorVersions": { + "methods": [ + "listProcessorVersions", + "listProcessorVersionsStream", + "listProcessorVersionsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-documentai/v1/src/v1/index.ts new file mode 100644 index 00000000000..db3b76d115a --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..27e40317e22 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* 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/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..b1548f79d2e --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1/system-test/install.ts b/owl-bot-staging/google-cloud-documentai/v1/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-documentai/v1/test/gapic_document_processor_service_v1.ts b/owl-bot-staging/google-cloud-documentai/v1/test/gapic_document_processor_service_v1.ts new file mode 100644 index 00000000000..67bce71db56 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/test/gapic_document_processor_service_v1.ts @@ -0,0 +1,3558 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DocumentProcessorServiceClient', () => { + describe('Common methods', () => { + 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 for the initialized client', done => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.documentProcessorServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentProcessorServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.processDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes processDocument with closed client', 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ProcessRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.processDocument(request), expectedError); + }); + }); + + describe('fetchProcessorTypes', () => { + it('invokes fetchProcessorTypes 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.FetchProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.FetchProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1.FetchProcessorTypesResponse() + ); + client.innerApiCalls.fetchProcessorTypes = stubSimpleCall(expectedResponse); + const [response] = await client.fetchProcessorTypes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchProcessorTypes 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.FetchProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.FetchProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1.FetchProcessorTypesResponse() + ); + client.innerApiCalls.fetchProcessorTypes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.fetchProcessorTypes( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchProcessorTypes 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.FetchProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.FetchProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.fetchProcessorTypes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.fetchProcessorTypes(request), expectedError); + const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchProcessorTypes with closed client', 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.FetchProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.FetchProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.fetchProcessorTypes(request), expectedError); + }); + }); + + describe('getProcessor', () => { + it('invokes getProcessor 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.GetProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1.Processor() + ); + client.innerApiCalls.getProcessor = stubSimpleCall(expectedResponse); + const [response] = await client.getProcessor(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessor 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.GetProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1.Processor() + ); + client.innerApiCalls.getProcessor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProcessor( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessor|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessor 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.GetProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProcessor = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProcessor(request), expectedError); + const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessor with closed client', 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.GetProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProcessor(request), expectedError); + }); + }); + + describe('getProcessorVersion', () => { + it('invokes getProcessorVersion 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.GetProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1.ProcessorVersion() + ); + client.innerApiCalls.getProcessorVersion = stubSimpleCall(expectedResponse); + const [response] = await client.getProcessorVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessorVersion 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.GetProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1.ProcessorVersion() + ); + client.innerApiCalls.getProcessorVersion = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProcessorVersion( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessorVersion|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessorVersion 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.GetProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProcessorVersion = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessorVersion with closed client', 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.GetProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProcessorVersion(request), expectedError); + }); + }); + + describe('createProcessor', () => { + it('invokes createProcessor 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.CreateProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.CreateProcessorRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1.Processor() + ); + client.innerApiCalls.createProcessor = stubSimpleCall(expectedResponse); + const [response] = await client.createProcessor(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProcessor 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.CreateProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.CreateProcessorRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1.Processor() + ); + client.innerApiCalls.createProcessor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProcessor( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessor|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProcessor 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.CreateProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.CreateProcessorRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProcessor = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProcessor(request), expectedError); + const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProcessor with closed client', 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.CreateProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.CreateProcessorRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProcessor(request), expectedError); + }); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.BatchProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.BatchProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.BatchProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.batchProcessDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.BatchProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.batchProcessDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('deleteProcessorVersion', () => { + it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProcessorVersion( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteProcessorVersionProgress 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.checkDeleteProcessorVersionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteProcessorVersionProgress 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.checkDeleteProcessorVersionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deployProcessorVersion', () => { + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(expectedResponse); + const [operation] = await client.deployProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deployProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deployProcessorVersion( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deployProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deployProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeployProcessorVersionProgress 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.checkDeployProcessorVersionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeployProcessorVersionProgress 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.checkDeployProcessorVersionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('undeployProcessorVersion', () => { + it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.UndeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(expectedResponse); + const [operation] = await client.undeployProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.UndeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeployProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeployProcessorVersion( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.UndeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.undeployProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.UndeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.undeployProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUndeployProcessorVersionProgress 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.checkUndeployProcessorVersionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUndeployProcessorVersionProgress 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.checkUndeployProcessorVersionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteProcessor', () => { + it('invokes deleteProcessor 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.DeleteProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProcessor 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.DeleteProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProcessor 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.DeleteProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteProcessor(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProcessor 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.DeleteProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteProcessor(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteProcessorProgress 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.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.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.checkDeleteProcessorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('enableProcessor', () => { + it('invokes enableProcessor 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.EnableProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.EnableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes enableProcessor 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.EnableProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.EnableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes enableProcessor 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.EnableProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.EnableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.enableProcessor(request), expectedError); + const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes enableProcessor 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.EnableProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.EnableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.enableProcessor(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkEnableProcessorProgress 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.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.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.checkEnableProcessorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('disableProcessor', () => { + it('invokes disableProcessor 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.DisableProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DisableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes disableProcessor 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.DisableProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DisableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes disableProcessor 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.DisableProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DisableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.disableProcessor(request), expectedError); + const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes disableProcessor 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.DisableProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.DisableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.disableProcessor(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDisableProcessorProgress 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.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.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.checkDisableProcessorProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('setDefaultProcessorVersion', () => { + it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.SetDefaultProcessorVersionRequest', ['processor']); + request.processor = defaultValue1; + const expectedHeaderRequestParams = `processor=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(expectedResponse); + const [operation] = await client.setDefaultProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.SetDefaultProcessorVersionRequest', ['processor']); + request.processor = defaultValue1; + const expectedHeaderRequestParams = `processor=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultProcessorVersion( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.SetDefaultProcessorVersionRequest', ['processor']); + request.processor = defaultValue1; + const expectedHeaderRequestParams = `processor=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setDefaultProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.SetDefaultProcessorVersionRequest', ['processor']); + request.processor = defaultValue1; + const expectedHeaderRequestParams = `processor=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setDefaultProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetDefaultProcessorVersionProgress 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.checkSetDefaultProcessorVersionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetDefaultProcessorVersionProgress 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.checkSetDefaultProcessorVersionProgress(''), 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ReviewDocumentRequest', ['humanReviewConfig']); + request.humanReviewConfig = defaultValue1; + const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ReviewDocumentRequest', ['humanReviewConfig']); + request.humanReviewConfig = defaultValue1; + const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ReviewDocumentRequest', ['humanReviewConfig']); + request.humanReviewConfig = defaultValue1; + const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.reviewDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ReviewDocumentRequest', ['humanReviewConfig']); + request.humanReviewConfig = defaultValue1; + const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.reviewDocument(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('listProcessorTypes', () => { + it('invokes listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + ]; + client.innerApiCalls.listProcessorTypes = stubSimpleCall(expectedResponse); + const [response] = await client.listProcessorTypes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + ]; + client.innerApiCalls.listProcessorTypes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProcessorTypes( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessorType[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProcessorTypes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProcessorTypes(request), expectedError); + const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorTypesStream 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + ]; + client.descriptors.page.listProcessorTypes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProcessorTypesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1.ProcessorType[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1.ProcessorType) => { + 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.listProcessorTypes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProcessorTypes, request)); + assert( + (client.descriptors.page.listProcessorTypes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProcessorTypesStream 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProcessorTypes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProcessorTypesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1.ProcessorType[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1.ProcessorType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProcessorTypes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProcessorTypes, request)); + assert( + (client.descriptors.page.listProcessorTypes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), + ]; + client.descriptors.page.listProcessorTypes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.documentai.v1.IProcessorType[] = []; + const iterable = client.listProcessorTypesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProcessorTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProcessorTypesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.documentai.v1.IProcessorType[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProcessors', () => { + it('invokes listProcessors 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.ListProcessorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + ]; + client.innerApiCalls.listProcessors = stubSimpleCall(expectedResponse); + const [response] = await client.listProcessors(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessors 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.ListProcessorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + ]; + client.innerApiCalls.listProcessors = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProcessors( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessor[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessors 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.ListProcessorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProcessors = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProcessors(request), expectedError); + const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorsStream 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.ListProcessorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1.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.v1.Processor[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1.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( + (client.descriptors.page.listProcessors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProcessorsStream 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.ListProcessorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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.v1.Processor[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1.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( + (client.descriptors.page.listProcessors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProcessors 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.ListProcessorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), + ]; + client.descriptors.page.listProcessors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.documentai.v1.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( + (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProcessors 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.ListProcessorsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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.v1.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( + (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProcessorVersions', () => { + it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + ]; + client.innerApiCalls.listProcessorVersions = stubSimpleCall(expectedResponse); + const [response] = await client.listProcessorVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + ]; + client.innerApiCalls.listProcessorVersions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProcessorVersions( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessorVersion[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProcessorVersions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProcessorVersions(request), expectedError); + const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorVersionsStream 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + ]; + client.descriptors.page.listProcessorVersions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProcessorVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1.ProcessorVersion[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1.ProcessorVersion) => { + 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.listProcessorVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProcessorVersions, request)); + assert( + (client.descriptors.page.listProcessorVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProcessorVersionsStream 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProcessorVersions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProcessorVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1.ProcessorVersion[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1.ProcessorVersion) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProcessorVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProcessorVersions, request)); + assert( + (client.descriptors.page.listProcessorVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), + ]; + client.descriptors.page.listProcessorVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.documentai.v1.IProcessorVersion[] = []; + const iterable = client.listProcessorVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProcessorVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProcessorVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.documentai.v1.IProcessorVersion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new documentprocessorserviceModule.v1.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.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)); + }); + }); + + describe('processorType', () => { + const fakePath = "/rendered/path/processorType"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + processor_type: "processorTypeValue", + }; + const client = new documentprocessorserviceModule.v1.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('processorVersion', () => { + const fakePath = "/rendered/path/processorVersion"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + processor: "processorValue", + processor_version: "processorVersionValue", + }; + const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.processorVersionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.processorVersionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('processorVersionPath', () => { + const result = client.processorVersionPath("projectValue", "locationValue", "processorValue", "processorVersionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.processorVersionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProcessorVersionName', () => { + const result = client.matchProjectFromProcessorVersionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProcessorVersionName', () => { + const result = client.matchLocationFromProcessorVersionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorFromProcessorVersionName', () => { + const result = client.matchProcessorFromProcessorVersionName(fakePath); + assert.strictEqual(result, "processorValue"); + assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorVersionFromProcessorVersionName', () => { + const result = client.matchProcessorVersionFromProcessorVersionName(fakePath); + assert.strictEqual(result, "processorVersionValue"); + assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new documentprocessorserviceModule.v1.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/google-cloud-documentai/v1/tsconfig.json b/owl-bot-staging/google-cloud-documentai/v1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/google-cloud-documentai/v1/webpack.config.js b/owl-bot-staging/google-cloud-documentai/v1/webpack.config.js new file mode 100644 index 00000000000..fc7bef574e6 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-documentai/v1beta1/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-documentai/v1beta1/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/.gitignore b/owl-bot-staging/google-cloud-documentai/v1beta1/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-documentai/v1beta1/.jsdoc.js new file mode 100644 index 00000000000..75c76e52a54 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/documentai', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-documentai/v1beta1/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-documentai/v1beta1/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/README.md b/owl-bot-staging/google-cloud-documentai/v1beta1/README.md new file mode 100644 index 00000000000..f41eef852ae --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/README.md @@ -0,0 +1 @@ +Documentai: Nodejs Client diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/linkinator.config.json b/owl-bot-staging/google-cloud-documentai/v1beta1/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/package.json b/owl-bot-staging/google-cloud-documentai/v1beta1/package.json new file mode 100644 index 00000000000..6cf1bfd4fec --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/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/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto b/owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto new file mode 100644 index 00000000000..aa95ecc2995 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/field_behavior.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; + + // Required. Entity type from a schema e.g. `Address`. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // 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/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto b/owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto new file mode 100644 index 00000000000..eb17286d4d5 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto b/owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto new file mode 100644 index 00000000000..5772db74511 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto @@ -0,0 +1,57 @@ +// 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; + + +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/google-cloud-documentai/v1beta1/samples/generated/v1beta1/document_understanding_service.batch_process_documents.js b/owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/document_understanding_service.batch_process_documents.js new file mode 100644 index 00000000000..1c7c32af24f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/document_understanding_service.batch_process_documents.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START documentai_v1beta1_generated_DocumentUnderstandingService_BatchProcessDocuments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Individual requests for each document. + */ + // const requests = 1234 + /** + * 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. + */ + // const parent = 'abc123' + + // Imports the Documentai library + const {DocumentUnderstandingServiceClient} = require('@google-cloud/documentai').v1beta1; + + // Instantiates a client + const documentaiClient = new DocumentUnderstandingServiceClient(); + + async function callBatchProcessDocuments() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await documentaiClient.batchProcessDocuments(request); + const [response] = await operation.promise(); + console.log(response); + } + + callBatchProcessDocuments(); + // [END documentai_v1beta1_generated_DocumentUnderstandingService_BatchProcessDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.documentai.v1beta1.json b/owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.documentai.v1beta1.json new file mode 100644 index 00000000000..134cb6b8536 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.documentai.v1beta1.json @@ -0,0 +1,59 @@ +{ + "clientLibrary": { + "name": "nodejs-documentai", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.documentai.v1beta1", + "version": "v1beta1" + } + ] + }, + "snippets": [ + { + "regionTag": "documentai_v1beta1_generated_DocumentUnderstandingService_BatchProcessDocuments_async", + "title": "DocumentUnderstandingService batchProcessDocuments Sample", + "origin": "API_DEFINITION", + "description": " LRO endpoint to batch process many documents.", + "canonical": true, + "file": "document_understanding_service.batch_process_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchProcessDocuments", + "fullName": "google.cloud.documentai.v1beta1.DocumentUnderstandingService.BatchProcessDocuments", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentUnderstandingServiceClient", + "fullName": "google.cloud.documentai.v1beta1.DocumentUnderstandingServiceClient" + }, + "method": { + "shortName": "BatchProcessDocuments", + "fullName": "google.cloud.documentai.v1beta1.DocumentUnderstandingService.BatchProcessDocuments", + "service": { + "shortName": "DocumentUnderstandingService", + "fullName": "google.cloud.documentai.v1beta1.DocumentUnderstandingService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/src/index.ts new file mode 100644 index 00000000000..8036bee84c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts new file mode 100644 index 00000000000..daf84de1622 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts @@ -0,0 +1,431 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} 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'; +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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new DocumentUnderstandingServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = []; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 -- + // ------------------- + +/** + * 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 include:samples/generated/v1beta1/document_understanding_service.batch_process_documents.js + * region_tag:documentai_v1beta1_generated_DocumentUnderstandingService_BatchProcessDocuments_async + */ + 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; + 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' + ] = this._gaxModule.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 include:samples/generated/v1beta1/document_understanding_service.batch_process_documents.js + * region_tag:documentai_v1beta1_generated_DocumentUnderstandingService_BatchProcessDocuments_async + */ + async checkBatchProcessDocumentsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, this._gaxModule.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 { + if (this.documentUnderstandingServiceStub && !this._terminated) { + return this.documentUnderstandingServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client_config.json b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client_config.json new file mode 100644 index 00000000000..2b4b0aff793 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_proto_list.json b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_proto_list.json new file mode 100644 index 00000000000..684a577c02a --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/gapic_metadata.json new file mode 100644 index 00000000000..a283d1de127 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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": "@google-cloud/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/google-cloud-documentai/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/index.ts new file mode 100644 index 00000000000..c274d629b37 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..38e85714680 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* 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/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..a4cb81abd01 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/test/gapic_document_understanding_service_v1beta1.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/test/gapic_document_understanding_service_v1beta1.ts new file mode 100644 index 00000000000..20d74d76637 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/test/gapic_document_understanding_service_v1beta1.ts @@ -0,0 +1,316 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function 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', () => { + describe('Common methods', () => { + 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 for the initialized client', done => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.documentUnderstandingServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentUnderstandingServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.batchProcessDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.batchProcessDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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/google-cloud-documentai/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-documentai/v1beta1/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-documentai/v1beta1/webpack.config.js new file mode 100644 index 00000000000..c6fdde56555 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/.eslintignore b/owl-bot-staging/google-cloud-documentai/v1beta2/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/.eslintrc.json b/owl-bot-staging/google-cloud-documentai/v1beta2/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/.gitignore b/owl-bot-staging/google-cloud-documentai/v1beta2/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/.jsdoc.js b/owl-bot-staging/google-cloud-documentai/v1beta2/.jsdoc.js new file mode 100644 index 00000000000..75c76e52a54 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/documentai', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/.mocharc.js b/owl-bot-staging/google-cloud-documentai/v1beta2/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/.prettierrc.js b/owl-bot-staging/google-cloud-documentai/v1beta2/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/README.md b/owl-bot-staging/google-cloud-documentai/v1beta2/README.md new file mode 100644 index 00000000000..f41eef852ae --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/README.md @@ -0,0 +1 @@ +Documentai: Nodejs Client diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/linkinator.config.json b/owl-bot-staging/google-cloud-documentai/v1beta2/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/package.json b/owl-bot-staging/google-cloud-documentai/v1beta2/package.json new file mode 100644 index 00000000000..6cf1bfd4fec --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto b/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto new file mode 100644 index 00000000000..a7255d7c1b9 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto @@ -0,0 +1,518 @@ +// 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"; + +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; + + // Required. Entity type from a schema e.g. `Address`. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // 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]; + } + + // 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; + + // 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 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/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto b/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto new file mode 100644 index 00000000000..137ba5e3116 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto b/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto new file mode 100644 index 00000000000..8c97cb995cf --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto @@ -0,0 +1,56 @@ +// 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; + + +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/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.batch_process_documents.js b/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.batch_process_documents.js new file mode 100644 index 00000000000..d8b7a19700e --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.batch_process_documents.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(requests) { + // [START documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Individual requests for each document. + */ + // const requests = 1234 + /** + * 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. + */ + // const parent = 'abc123' + + // Imports the Documentai library + const {DocumentUnderstandingServiceClient} = require('@google-cloud/documentai').v1beta2; + + // Instantiates a client + const documentaiClient = new DocumentUnderstandingServiceClient(); + + async function callBatchProcessDocuments() { + // Construct request + const request = { + requests, + }; + + // Run request + const [operation] = await documentaiClient.batchProcessDocuments(request); + const [response] = await operation.promise(); + console.log(response); + } + + callBatchProcessDocuments(); + // [END documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.process_document.js b/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.process_document.js new file mode 100644 index 00000000000..caf92fe342a --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.process_document.js @@ -0,0 +1,104 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(inputConfig) { + // [START documentai_v1beta2_generated_DocumentUnderstandingService_ProcessDocument_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * 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. + */ + // const parent = 'abc123' + /** + * Required. Information about the input file. + */ + // const inputConfig = {} + /** + * Optional. The desired output location. This field is only needed in + * BatchProcessDocumentsRequest. + */ + // const outputConfig = {} + /** + * 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. + */ + // const documentType = 'abc123' + /** + * Controls table extraction behavior. If not specified, the system will + * decide reasonable defaults. + */ + // const tableExtractionParams = {} + /** + * Controls form extraction behavior. If not specified, the system will + * decide reasonable defaults. + */ + // const formExtractionParams = {} + /** + * Controls entity extraction behavior. If not specified, the system will + * decide reasonable defaults. + */ + // const entityExtractionParams = {} + /** + * Controls OCR behavior. If not specified, the system will decide reasonable + * defaults. + */ + // const ocrParams = {} + /** + * Controls AutoML model prediction behavior. AutoMlParams cannot be used + * together with other Params. + */ + // const automlParams = {} + + // Imports the Documentai library + const {DocumentUnderstandingServiceClient} = require('@google-cloud/documentai').v1beta2; + + // Instantiates a client + const documentaiClient = new DocumentUnderstandingServiceClient(); + + async function callProcessDocument() { + // Construct request + const request = { + inputConfig, + }; + + // Run request + const response = await documentaiClient.processDocument(request); + console.log(response); + } + + callProcessDocument(); + // [END documentai_v1beta2_generated_DocumentUnderstandingService_ProcessDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.documentai.v1beta2.json b/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.documentai.v1beta2.json new file mode 100644 index 00000000000..a872a6a555f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.documentai.v1beta2.json @@ -0,0 +1,131 @@ +{ + "clientLibrary": { + "name": "nodejs-documentai", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.documentai.v1beta2", + "version": "v1beta2" + } + ] + }, + "snippets": [ + { + "regionTag": "documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async", + "title": "DocumentUnderstandingService batchProcessDocuments Sample", + "origin": "API_DEFINITION", + "description": " LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.", + "canonical": true, + "file": "document_understanding_service.batch_process_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchProcessDocuments", + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.BatchProcessDocuments", + "async": true, + "parameters": [ + { + "name": "requests", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentUnderstandingServiceClient", + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient" + }, + "method": { + "shortName": "BatchProcessDocuments", + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.BatchProcessDocuments", + "service": { + "shortName": "DocumentUnderstandingService", + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService" + } + } + } + }, + { + "regionTag": "documentai_v1beta2_generated_DocumentUnderstandingService_ProcessDocument_async", + "title": "DocumentUnderstandingService processDocument Sample", + "origin": "API_DEFINITION", + "description": " Processes a single document.", + "canonical": true, + "file": "document_understanding_service.process_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 96, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ProcessDocument", + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.ProcessDocument", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "input_config", + "type": ".google.cloud.documentai.v1beta2.InputConfig" + }, + { + "name": "output_config", + "type": ".google.cloud.documentai.v1beta2.OutputConfig" + }, + { + "name": "document_type", + "type": "TYPE_STRING" + }, + { + "name": "table_extraction_params", + "type": ".google.cloud.documentai.v1beta2.TableExtractionParams" + }, + { + "name": "form_extraction_params", + "type": ".google.cloud.documentai.v1beta2.FormExtractionParams" + }, + { + "name": "entity_extraction_params", + "type": ".google.cloud.documentai.v1beta2.EntityExtractionParams" + }, + { + "name": "ocr_params", + "type": ".google.cloud.documentai.v1beta2.OcrParams" + }, + { + "name": "automl_params", + "type": ".google.cloud.documentai.v1beta2.AutoMlParams" + } + ], + "resultType": ".google.cloud.documentai.v1beta2.Document", + "client": { + "shortName": "DocumentUnderstandingServiceClient", + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient" + }, + "method": { + "shortName": "ProcessDocument", + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.ProcessDocument", + "service": { + "shortName": "DocumentUnderstandingService", + "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/src/index.ts new file mode 100644 index 00000000000..c40cad8fe68 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts new file mode 100644 index 00000000000..40473d60f3e --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts @@ -0,0 +1,532 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} 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'; +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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new DocumentUnderstandingServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = []; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 -- + // ------------------- +/** + * 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 include:samples/generated/v1beta2/document_understanding_service.process_document.js + * region_tag:documentai_v1beta2_generated_DocumentUnderstandingService_ProcessDocument_async + */ + 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; + 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.processDocument(request, options, callback); + } + +/** + * 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 include:samples/generated/v1beta2/document_understanding_service.batch_process_documents.js + * region_tag:documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async + */ + 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; + 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' + ] = this._gaxModule.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 include:samples/generated/v1beta2/document_understanding_service.batch_process_documents.js + * region_tag:documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async + */ + async checkBatchProcessDocumentsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, this._gaxModule.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 { + if (this.documentUnderstandingServiceStub && !this._terminated) { + return this.documentUnderstandingServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client_config.json b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client_config.json new file mode 100644 index 00000000000..1dea85e9656 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_proto_list.json b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_proto_list.json new file mode 100644 index 00000000000..ee1f3779a2c --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/src/v1beta2/gapic_metadata.json b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/gapic_metadata.json new file mode 100644 index 00000000000..49efed8a754 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/src/v1beta2/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/index.ts new file mode 100644 index 00000000000..c274d629b37 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..38e85714680 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* 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/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..a4cb81abd01 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1beta2/system-test/install.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/test/gapic_document_understanding_service_v1beta2.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/test/gapic_document_understanding_service_v1beta2.ts new file mode 100644 index 00000000000..3a849df02a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/test/gapic_document_understanding_service_v1beta2.ts @@ -0,0 +1,428 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +describe('v1beta2.DocumentUnderstandingServiceClient', () => { + describe('Common methods', () => { + 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 for the initialized client', done => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.documentUnderstandingServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentUnderstandingServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta2.ProcessDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta2.ProcessDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta2.ProcessDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.processDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes processDocument with closed client', 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta2.ProcessDocumentRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.processDocument(request), expectedError); + }); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.batchProcessDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.batchProcessDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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/google-cloud-documentai/v1beta2/tsconfig.json b/owl-bot-staging/google-cloud-documentai/v1beta2/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/webpack.config.js b/owl-bot-staging/google-cloud-documentai/v1beta2/webpack.config.js new file mode 100644 index 00000000000..c6fdde56555 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta3/.eslintignore b/owl-bot-staging/google-cloud-documentai/v1beta3/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/.eslintrc.json b/owl-bot-staging/google-cloud-documentai/v1beta3/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/.gitignore b/owl-bot-staging/google-cloud-documentai/v1beta3/.gitignore new file mode 100644 index 00000000000..5d32b23782f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta3/.jsdoc.js b/owl-bot-staging/google-cloud-documentai/v1beta3/.jsdoc.js new file mode 100644 index 00000000000..75c76e52a54 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/documentai', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/.mocharc.js b/owl-bot-staging/google-cloud-documentai/v1beta3/.mocharc.js new file mode 100644 index 00000000000..481c522b00f --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/.prettierrc.js b/owl-bot-staging/google-cloud-documentai/v1beta3/.prettierrc.js new file mode 100644 index 00000000000..494e147865d --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/README.md b/owl-bot-staging/google-cloud-documentai/v1beta3/README.md new file mode 100644 index 00000000000..f41eef852ae --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/README.md @@ -0,0 +1 @@ +Documentai: Nodejs Client diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/linkinator.config.json b/owl-bot-staging/google-cloud-documentai/v1beta3/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/package.json b/owl-bot-staging/google-cloud-documentai/v1beta3/package.json new file mode 100644 index 00000000000..41e8970a7ad --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.2" + }, + "devDependencies": { + "@types/mocha": "^9.1.1", + "@types/node": "^16.11.62", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^3.6.11", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.0.3", + "mocha": "^10.0.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^14.0.0", + "ts-loader": "^8.4.0", + "typescript": "^4.8.3", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/barcode.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/barcode.proto new file mode 100644 index 00000000000..9b063faf287 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/barcode.proto @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +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 = "BarcodeProto"; +option java_package = "com.google.cloud.documentai.v1beta3"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; + +// Encodes the detailed information of a barcode. +message Barcode { + // Format of a barcode. + // The supported formats are: + // + // - `CODE_128`: Code 128 type. + // - `CODE_39`: Code 39 type. + // - `CODE_93`: Code 93 type. + // - `CODABAR`: Codabar type. + // - `DATA_MATRIX`: 2D Data Matrix type. + // - `ITF`: ITF type. + // - `EAN_13`: EAN-13 type. + // - `EAN_8`: EAN-8 type. + // - `QR_CODE`: 2D QR code type. + // - `UPC_A`: UPC-A type. + // - `UPC_E`: UPC-E type. + // - `PDF417`: PDF417 type. + // - `AZTEC`: 2D Aztec code type. + // - `DATABAR`: GS1 DataBar code type. + string format = 1; + + // Value format describes the format of the value that a barcode + // encodes. + // The supported formats are: + // + // - `CONTACT_INFO`: Contact information. + // - `EMAIL`: Email address. + // - `ISBN`: ISBN identifier. + // - `PHONE`: Phone number. + // - `PRODUCT`: Product. + // - `SMS`: SMS message. + // - `TEXT`: Text string. + // - `URL`: URL address. + // - `WIFI`: Wifi information. + // - `GEO`: Geo-localization. + // - `CALENDAR_EVENT`: Calendar event. + // - `DRIVER_LICENSE`: Driver's license. + string value_format = 2; + + // Raw value encoded in the barcode. + // For example: `'MEBKM:TITLE:Google;URL:https://www.google.com;;'`. + string raw_value = 3; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto new file mode 100644 index 00000000000..2ae46db8e24 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto @@ -0,0 +1,820 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +import "google/api/field_behavior.proto"; +import "google/cloud/documentai/v1beta3/barcode.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"; + +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 AI. It is an +// interchange format that provides insights into documents and allows for +// collaboration between users and Document AI to iterate and optimize for +// quality. +message Document { + // For a large document, sharding may be performed to produce several + // document shards. Each document shard contains this field to detail which + // shard it is. + message ShardInfo { + // The 0-based index of this shard. + int64 shard_index = 1; + + // Total number of shards. + int64 shard_count = 2; + + // The index of the first character in [Document.text][google.cloud.documentai.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; + + // Font family such as `Arial`, `Times New Roman`. + // https://www.w3schools.com/cssref/pr_font_font-family.asp + string font_family = 8; + } + + // A page in a [Document][google.cloud.documentai.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 [deprecated = true]; + } + + // 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 [deprecated = true]; + } + + // A collection of tokens that a human would perceive as a line. + // Does not cross column boundaries, can be horizontal, vertical, etc. + message Line { + // [Layout][google.cloud.documentai.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 [deprecated = true]; + } + + // 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 [deprecated = true]; + } + + // A detected symbol. + message Symbol { + // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [Symbol][google.cloud.documentai.v1beta3.Document.Page.Symbol]. + Layout layout = 1; + + // A list of detected languages together with confidence. + repeated DetectedLanguage detected_languages = 2; + } + + // Detected non-text visual elements e.g. checkbox, signature etc. on the + // page. + message VisualElement { + // [Layout][google.cloud.documentai.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; + + // The history of this table. + Provenance provenance = 5; + } + + // 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; + + // Created for Labeling UI to export key text. + // If corrections were made to the text identified by the + // `field_name.text_anchor`, this field will contain the correction. + string corrected_key_text = 6; + + // Created for Labeling UI to export value text. + // If corrections were made to the text identified by the + // `field_value.text_anchor`, this field will contain the correction. + string corrected_value_text = 7; + + // The history of this annotation. + Provenance provenance = 8; + } + + // A detected barcode. + message DetectedBarcode { + // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [DetectedBarcode][google.cloud.documentai.v1beta3.Document.Page.DetectedBarcode]. + Layout layout = 1; + + // Detailed barcode information of the [DetectedBarcode][google.cloud.documentai.v1beta3.Document.Page.DetectedBarcode]. + Barcode barcode = 2; + } + + // Detected language for a structural component. + message DetectedLanguage { + // The BCP-47 language code, such as `en-US` or `sr-Latn`. For more + // information, see + // https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 1; + + // Confidence of detected language. Range `[0, 1]`. + float confidence = 2; + } + + // Image Quality Scores for the page image + message ImageQualityScores { + // Image Quality Defects + message DetectedDefect { + // Name of the defect type. Supported values are: + // + // - `quality/defect_blurry` + // - `quality/defect_noisy` + // - `quality/defect_dark` + // - `quality/defect_faint` + // - `quality/defect_text_too_small` + // - `quality/defect_document_cutoff` + // - `quality/defect_text_cutoff` + // - `quality/defect_glare` + string type = 1; + + // Confidence of detected defect. Range `[0, 1]` where 1 indicates + // strong confidence of that the defect exists. + float confidence = 2; + } + + // The overall quality score. Range `[0, 1]` where 1 is perfect quality. + float quality_score = 1; + + // A list of detected defects. + repeated DetectedDefect detected_defects = 2; + } + + // 1-based index for current [Page][google.cloud.documentai.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; + + // A list of visually detected symbols on the page. + repeated Symbol symbols = 12; + + // A list of detected barcodes. + repeated DetectedBarcode detected_barcodes = 15; + + // Image Quality Scores. + ImageQualityScores image_quality_scores = 17; + + // The history of this page. + Provenance provenance = 16 [deprecated = true]; + } + + // An entity that could be a phrase in the text or a property that belongs to + // the document. It is a known entity type, such as a person, an organization, + // or location. + message Entity { + // Parsed and normalized entity value. + message NormalizedValue { + // An optional structured entity value. + // Must match entity type defined in schema if + // known. If this field is present, the `text` field could also be + // populated. + oneof structured_value { + // Money value. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/money.proto + google.type.Money money_value = 2; + + // Date value. Includes year, month, day. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/date.proto + google.type.Date date_value = 3; + + // DateTime value. Includes date, time, and timezone. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto + google.type.DateTime datetime_value = 4; + + // Postal address. See also: + // https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto + google.type.PostalAddress address_value = 5; + + // Boolean value. Can be used for entities with binary values, or for + // checkboxes. + bool boolean_value = 6; + + // Integer value. + int32 integer_value = 7; + + // Float value. + float float_value = 8; + } + + // Optional. An optional field to store a normalized string. + // For some entity types, one of respective `structured_value` fields may + // also be populated. Also not all the types of `structured_value` will be + // normalized. For example, some processors may not generate float + // or int normalized text by default. + // + // Below are sample formats mapped to structured values. + // + // - Money/Currency type (`money_value`) is in the ISO 4217 text format. + // - Date type (`date_value`) is in the ISO 8601 text format. + // - Datetime type (`datetime_value`) is in the ISO 8601 text format. + string text = 1 [(google.api.field_behavior) = OPTIONAL]; + } + + // Optional. Provenance of the entity. + // Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta3.Document.text]. + TextAnchor text_anchor = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Required. Entity type from a schema e.g. `Address`. + string type = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`. + string mention_text = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Deprecated. Use `id` field instead. + string mention_id = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Confidence of detected Schema entity. Range `[0, 1]`. + float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Represents the provenance of this entity wrt. the location on the + // page where it was found. + PageAnchor page_anchor = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Canonical id. This will be a unique value in the entity list + // for this document. + string id = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Normalized entity value. Absent if the extracted value could not be + // converted or the type (e.g. address) is not supported for certain + // parsers. This field is also only populated for certain supported document + // types. + NormalizedValue normalized_value = 9 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Entities can be nested to form a hierarchical data structure representing + // the content in the document. + repeated Entity properties = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The history of this annotation. + Provenance provenance = 11 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Whether the entity will be redacted for de-identification purposes. + bool redacted = 12 [(google.api.field_behavior) = OPTIONAL]; + } + + // Relationship between [Entities][google.cloud.documentai.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. It is always + // populated for formFields. + 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 { + // The parent element the current element is based on. Used for + // referencing/aligning, removal and replacement operations. + message Parent { + // The index of the index into current revision's parent_ids list. + int32 revision = 1; + + // The index of the parent item in the corresponding item list (eg. list + // of entities, properties within entities, etc.) in the parent revision. + int32 index = 3; + + // The id of the parent provenance. + int32 id = 2 [deprecated = true]; + } + + // If a processor or agent does an explicit operation on existing elements. + enum OperationType { + // Operation type unspecified. If no operation is specified a provenance + // entry is simply used to match against a `parent`. + OPERATION_TYPE_UNSPECIFIED = 0; + + // Add an element. + ADD = 1; + + // Remove an element identified by `parent`. + REMOVE = 2; + + // Replace an element identified by `parent`. + REPLACE = 3; + + // Request human review for the element identified by `parent`. + EVAL_REQUESTED = 4; + + // Element is reviewed and approved at human review, confidence will be + // set to 1.0. + EVAL_APPROVED = 5; + + // Element is skipped in the validation process. + EVAL_SKIPPED = 6; + } + + // The index of the revision that produced this element. + int32 revision = 1; + + // The Id of this operation. Needs to be unique within the scope of the + // revision. + int32 id = 2 [deprecated = true]; + + // References to the original elements that are replaced. + repeated Parent parents = 3; + + // The type of provenance operation. + OperationType type = 4; + } + + // Contains past or forward revisions of this document. + message Revision { + // Human Review information of the document. + message HumanReview { + // Human review state. e.g. `requested`, `succeeded`, `rejected`. + string state = 1; + + // A message providing more details about the current state of processing. + // For example, the rejection reason when the state is `rejected`. + string state_message = 2; + } + + // Who/what made the change + oneof source { + // If the change was made by a person specify the name or id of that + // person. + string agent = 4; + + // If the annotation was made by processor identify the processor by its + // resource name. + string processor = 5; + } + + // Id of the revision. Unique within the context of the document. + string id = 1; + + // The revisions that this revision is based on. This can include one or + // more parent (when documents are merged.) This field represents the + // index into the `revisions` field. + repeated int32 parent = 2 [deprecated = true]; + + // The revisions that this revision is based on. Must include all the ids + // that have anything to do with this revision - eg. there are + // `provenance.parent.revision` fields that index into this field. + repeated string parent_ids = 7; + + // The time that the revision was created. + google.protobuf.Timestamp create_time = 3; + + // Human Review information of this revision. + HumanReview human_review = 6; + } + + // This message is used for text changes aka. OCR corrections. + message TextChange { + // Provenance of the correction. + // Text anchor indexing into the [Document.text][google.cloud.documentai.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 [deprecated = true]; + } + + // Original source document from the user. + oneof source { + // Optional. Currently supports Google Cloud Storage URI of the form + // `gs://bucket_name/object_name`. Object versioning is not supported. + // See [Google Cloud Storage Request + // URIs](https://cloud.google.com/storage/docs/reference-uris) for more + // info. + string uri = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Inline document content, represented as a stream of bytes. + // Note: As with all `bytes` fields, protobuffers use a pure binary + // representation, whereas JSON representations use base64. + bytes content = 2 [(google.api.field_behavior) = OPTIONAL]; + } + + // An IANA published MIME type (also referred to as media type). For more + // information, see + // https://www.iana.org/assignments/media-types/media-types.xhtml. + string mime_type = 3; + + // Optional. UTF-8 encoded text in reading order from the document. + string text = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Placeholder. Styles for the [Document.text][google.cloud.documentai.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; + + // Placeholder. Relationship among [Document.entities][google.cloud.documentai.v1beta3.Document.entities]. + repeated EntityRelation entity_relations = 8; + + // Placeholder. A list of text corrections made to [Document.text][google.cloud.documentai.v1beta3.Document.text]. This + // is usually used for annotating corrections to OCR mistakes. Text changes + // for a given revision may not overlap with each other. + repeated TextChange text_changes = 14; + + // Information about the sharding if this document is sharded part of a larger + // document. If the document is not sharded, this message is not specified. + ShardInfo shard_info = 9; + + // Any error that occurred while processing this document. + google.rpc.Status error = 10; + + // Placeholder. Revision history of this document. + repeated Revision revisions = 13; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto new file mode 100644 index 00000000000..e10bea84087 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto @@ -0,0 +1,84 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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; + +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][google.cloud.documentai.v1beta3.RawDocument.content]. + string mime_type = 2; +} + +// Specifies a document stored on Cloud Storage. +message GcsDocument { + // The Cloud Storage object uri. + string gcs_uri = 1; + + // An IANA MIME type (RFC6838) of the content. + string mime_type = 2; +} + +// Specifies a set of documents on Cloud Storage. +message GcsDocuments { + // The list of documents. + repeated GcsDocument documents = 1; +} + +// Specifies all documents on Cloud Storage with a common prefix. +message GcsPrefix { + // The URI prefix. + string gcs_uri_prefix = 1; +} + +// The common config to specify a set of documents used as input. +message BatchDocumentsInputConfig { + // The source. + oneof source { + // The set of documents that match the specified Cloud Storage `gcs_prefix`. + GcsPrefix gcs_prefix = 1; + + // The set of documents individually specified on Cloud Storage. + GcsDocuments gcs_documents = 2; + } +} + +// Config that controls the output of documents. All documents will be written +// as a JSON file. +message DocumentOutputConfig { + // The configuration used when outputting documents. + message GcsOutputConfig { + // The 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/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto new file mode 100644 index 00000000000..34e3380413b --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto @@ -0,0 +1,1070 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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/document_schema.proto"; +import "google/cloud/documentai/v1beta3/evaluation.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"; +option (google.api.resource_definition) = { + type: "documentai.googleapis.com/HumanReviewConfig" + pattern: "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" +}; +option (google.api.resource_definition) = { + type: "documentai.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; + +// Service to call Cloud DocumentAI to process documents according to the +// processor's definition. Processors are built using state-of-the-art Google +// AI such as natural language, computer vision, and translation to extract +// structured information from unstructured or semi-structured documents. +service DocumentProcessorService { + option (google.api.default_host) = "documentai.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Processes a single document. + rpc ProcessDocument(ProcessRequest) returns (ProcessResponse) { + option (google.api.http) = { + post: "/v1beta3/{name=projects/*/locations/*/processors/*}:process" + body: "*" + additional_bindings { + post: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}:process" + body: "*" + } + }; + option (google.api.method_signature) = "name"; + } + + // LRO endpoint to batch process many documents. The output is written + // to Cloud Storage as JSON in the [Document] format. + rpc BatchProcessDocuments(BatchProcessRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta3/{name=projects/*/locations/*/processors/*}:batchProcess" + body: "*" + additional_bindings { + post: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}:batchProcess" + body: "*" + } + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "BatchProcessResponse" + metadata_type: "BatchProcessMetadata" + }; + } + + // Fetches processor types. Note that we do not use ListProcessorTypes here + // because it is not paginated. + rpc FetchProcessorTypes(FetchProcessorTypesRequest) returns (FetchProcessorTypesResponse) { + option (google.api.http) = { + get: "/v1beta3/{parent=projects/*/locations/*}:fetchProcessorTypes" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists the processor types that exist. + rpc ListProcessorTypes(ListProcessorTypesRequest) returns (ListProcessorTypesResponse) { + option (google.api.http) = { + get: "/v1beta3/{parent=projects/*/locations/*}/processorTypes" + }; + option (google.api.method_signature) = "parent"; + } + + // Lists all processors which belong to this project. + rpc ListProcessors(ListProcessorsRequest) returns (ListProcessorsResponse) { + option (google.api.http) = { + get: "/v1beta3/{parent=projects/*/locations/*}/processors" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a processor detail. + rpc GetProcessor(GetProcessorRequest) returns (Processor) { + option (google.api.http) = { + get: "/v1beta3/{name=projects/*/locations/*/processors/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Trains a new processor version. + // Operation metadata is returned as + // cloud_documentai_core.TrainProcessorVersionMetadata. + rpc TrainProcessorVersion(TrainProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta3/{parent=projects/*/locations/*/processors/*}/processorVersions:train" + body: "*" + }; + option (google.api.method_signature) = "parent,processor_version"; + option (google.longrunning.operation_info) = { + response_type: "TrainProcessorVersionResponse" + metadata_type: "TrainProcessorVersionMetadata" + }; + } + + // Gets a processor version detail. + rpc GetProcessorVersion(GetProcessorVersionRequest) returns (ProcessorVersion) { + option (google.api.http) = { + get: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all versions of a processor. + rpc ListProcessorVersions(ListProcessorVersionsRequest) returns (ListProcessorVersionsResponse) { + option (google.api.http) = { + get: "/v1beta3/{parent=projects/*/locations/*/processors/*}/processorVersions" + }; + option (google.api.method_signature) = "parent"; + } + + // Deletes the processor version, all artifacts under the processor version + // will be deleted. + rpc DeleteProcessorVersion(DeleteProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "DeleteProcessorVersionMetadata" + }; + } + + // Deploys the processor version. + rpc DeployProcessorVersion(DeployProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}:deploy" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "DeployProcessorVersionResponse" + metadata_type: "DeployProcessorVersionMetadata" + }; + } + + // Undeploys the processor version. + rpc UndeployProcessorVersion(UndeployProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}:undeploy" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "UndeployProcessorVersionResponse" + metadata_type: "UndeployProcessorVersionMetadata" + }; + } + + // Creates a processor from the type processor that the user chose. + // The processor will be at "ENABLED" state by default after its creation. + rpc CreateProcessor(CreateProcessorRequest) returns (Processor) { + option (google.api.http) = { + post: "/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" + }; + } + + // Set the default (active) version of a [Processor][google.cloud.documentai.v1beta3.Processor] that will be used in + // [ProcessDocument][google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument] and + // [BatchProcessDocuments][google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments]. + rpc SetDefaultProcessorVersion(SetDefaultProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta3/{processor=projects/*/locations/*/processors/*}:setDefaultProcessorVersion" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "SetDefaultProcessorVersionResponse" + metadata_type: "SetDefaultProcessorVersionMetadata" + }; + } + + // Send a document for Human Review. The input document should be processed by + // the specified processor. + rpc ReviewDocument(ReviewDocumentRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/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" + }; + } + + // Evaluates a ProcessorVersion against annotated documents, producing an + // Evaluation. + rpc EvaluateProcessorVersion(EvaluateProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta3/{processor_version=projects/*/locations/*/processors/*/processorVersions/*}:evaluateProcessorVersion" + body: "*" + }; + option (google.api.method_signature) = "processor_version"; + option (google.longrunning.operation_info) = { + response_type: "EvaluateProcessorVersionResponse" + metadata_type: "EvaluateProcessorVersionMetadata" + }; + } + + // Retrieves a specific evaluation. + rpc GetEvaluation(GetEvaluationRequest) returns (Evaluation) { + option (google.api.http) = { + get: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*/evaluations/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Retrieves a set of evaluations for a given processor version. + rpc ListEvaluations(ListEvaluationsRequest) returns (ListEvaluationsResponse) { + option (google.api.http) = { + get: "/v1beta3/{parent=projects/*/locations/*/processors/*/processorVersions/*}/evaluations" + }; + option (google.api.method_signature) = "parent"; + } +} + +// Request message for the process document method. +message ProcessRequest { + // The document payload. + oneof source { + // An inline document proto. + Document inline_document = 4; + + // A raw document content (bytes). + RawDocument raw_document = 5; + } + + // Required. The resource name of the [Processor][google.cloud.documentai.v1beta3.Processor] or + // [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion] + // to use for processing. If a [Processor][google.cloud.documentai.v1beta3.Processor] is specified, the server will use + // its [default version][google.cloud.documentai.v1beta3.Processor.default_processor_version]. Format: + // `projects/{project}/locations/{location}/processors/{processor}`, or + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "*" + } + ]; + + // 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; + + // Specifies which fields to include in ProcessResponse's document. + // Only supports top level document and pages field so it must be in the form + // of `{document_field_name}` or `pages.{page_field_name}`. + google.protobuf.FieldMask field_mask = 6; +} + +// The status of human review on a processed document. +message HumanReviewStatus { + // The final state of human review on a processed document. + enum State { + // Human review state is unspecified. Most likely due to an internal error. + STATE_UNSPECIFIED = 0; + + // Human review is skipped for the document. This can happen because human + // review is not enabled on the processor or the processing request has + // been set to skip this document. + SKIPPED = 1; + + // Human review validation is triggered and passed, so no review is needed. + VALIDATION_PASSED = 2; + + // Human review validation is triggered and the document is under review. + IN_PROGRESS = 3; + + // Some error happened during triggering human review, see the + // [state_message] for details. + ERROR = 4; + } + + // The state of human review on the processing request. + State state = 1; + + // A message providing more details about the human review state. + string state_message = 2; + + // The name of the operation triggered by the processed document. This field + // is populated only when the [state] is [HUMAN_REVIEW_IN_PROGRESS]. It has + // the same response type and metadata as the long running operation returned + // by [ReviewDocument] method. + string human_review_operation = 3; +} + +// Response message for the process document method. +message ProcessResponse { + // The document payload, will populate fields based on the processor's + // behavior. + Document document = 1; + + // The 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 resource name of [Processor][google.cloud.documentai.v1beta3.Processor] or + // [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion]. + // Format: `projects/{project}/locations/{location}/processors/{processor}`, + // or + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "*" + } + ]; + + // The input 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 processing the document. + google.rpc.Status status = 2; + + // The output_gcs_destination (in the request as `output_gcs_destination`) + // of the processed document if it was successful, otherwise empty. + string output_gcs_destination = 3; + + // The 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. + // The available processor types may depend on the allow-listing on projects. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorType" + } + ]; +} + +// Response message for fetch processor types. +message FetchProcessorTypesResponse { + // The list of processor types. + repeated ProcessorType processor_types = 1; +} + +// Request message for list processor types. +message ListProcessorTypesRequest { + // Required. The location of processor type to list. + // The available processor types may depend on the allow-listing on projects. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorType" + } + ]; + + // The maximum number of processor types to return. + // If unspecified, at most 100 processor types will be returned. + // The maximum value is 500; values above 500 will be coerced to 500. + int32 page_size = 2; + + // Used to retrieve the next page of results, empty if at the end of the list. + string page_token = 3; +} + +// Response message for list processor types. +message ListProcessorTypesResponse { + // The processor types. + repeated ProcessorType processor_types = 1; + + // Points to the next page, otherwise empty. + string next_page_token = 2; +} + +// Request message for list all processors belongs to a project. +message ListProcessorsRequest { + // Required. The parent (project and location) which owns this collection of Processors. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/Processor" + } + ]; + + // The maximum number of processors to return. + // If unspecified, at most 50 processors will be returned. + // The maximum value is 100; values above 100 will be coerced to 100. + int32 page_size = 2; + + // We will return the processors sorted by creation time. The page token + // will point to the next processor. + string page_token = 3; +} + +// Response message for list processors. +message ListProcessorsResponse { + // The list of processors. + repeated Processor processors = 1; + + // Points to the next processor, otherwise empty. + string next_page_token = 2; +} + +// Request message for get processor. +message GetProcessorRequest { + // Required. The processor resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// Request message for get processor version. +message GetProcessorVersionRequest { + // Required. The processor resource name. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Request message for list all processor versions belongs to a processor. +message ListProcessorVersionsRequest { + // Required. The parent (project, location and processor) to list all versions. + // Format: `projects/{project}/locations/{location}/processors/{processor}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorVersion" + } + ]; + + // The maximum number of processor versions to return. + // If unspecified, at most 10 processor versions will be returned. + // The maximum value is 20; values above 20 will be coerced to 20. + int32 page_size = 2; + + // We will return the processor versions sorted by creation time. The page + // token will point to the next processor version. + string page_token = 3; +} + +// Response message for list processors. +message ListProcessorVersionsResponse { + // The list of processors. + repeated ProcessorVersion processor_versions = 1; + + // Points to the next processor, otherwise empty. + string next_page_token = 2; +} + +// Request message for the delete processor version method. +message DeleteProcessorVersionRequest { + // Required. The processor version resource name to be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// The long running operation metadata for delete processor version method. +message DeleteProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for the deploy processor version method. +message DeployProcessorVersionRequest { + // Required. The processor version resource name to be deployed. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Response message for the deploy processor version method. +message DeployProcessorVersionResponse { + +} + +// The long running operation metadata for deploy processor version method. +message DeployProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for the undeploy processor version method. +message UndeployProcessorVersionRequest { + // Required. The processor version resource name to be undeployed. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Response message for the undeploy processor version method. +message UndeployProcessorVersionResponse { + +} + +// The long running operation metadata for the undeploy processor version +// method. +message UndeployProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for create a processor. Notice this request is sent to +// a regionalized backend service, and if the processor type is not available +// on that region, the creation will fail. +message CreateProcessorRequest { + // Required. The parent (project and location) under which to create the processor. + // Format: `projects/{project}/locations/{location}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/Processor" + } + ]; + + // Required. The processor to be created, requires [processor_type] and [display_name] + // to be set. Also, the processor is under CMEK if CMEK fields are set. + Processor processor = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for the delete processor method. +message DeleteProcessorRequest { + // Required. The processor resource name to be deleted. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// The long running operation metadata for delete processor method. +message DeleteProcessorMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} + +// Request message for the enable processor method. +message EnableProcessorRequest { + // Required. The processor resource name to be enabled. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// Response message for the enable processor method. +// Intentionally empty proto for adding fields in future. +message EnableProcessorResponse { + +} + +// The long running operation metadata for enable processor method. +message EnableProcessorMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} + +// Request message for the disable processor method. +message DisableProcessorRequest { + // Required. The processor resource name to be disabled. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; +} + +// Response message for the disable processor method. +// Intentionally empty proto for adding fields in future. +message DisableProcessorResponse { + +} + +// The long running operation metadata for disable processor method. +message DisableProcessorMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 5; +} + +// Request message for the set default processor version method. +message SetDefaultProcessorVersionRequest { + // Required. The resource name of the [Processor][google.cloud.documentai.v1beta3.Processor] to change default version. + string processor = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Processor" + } + ]; + + // Required. The resource name of child [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion] to use as default. + // Format: + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` + string default_processor_version = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; +} + +// Response message for set default processor version method. +message SetDefaultProcessorVersionResponse { + +} + +// The long running operation metadata for set default processor version +// method. +message SetDefaultProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Request message for the create processor version method. +message TrainProcessorVersionRequest { + // The input data used to train a new `ProcessorVersion`. + message InputData { + // The documents used for training the new version. + BatchDocumentsInputConfig training_documents = 3; + + // The documents used for testing the trained version. + BatchDocumentsInputConfig test_documents = 4; + } + + // Required. The parent (project, location and processor) to create the new version for. + // Format: `projects/{project}/locations/{location}/processors/{processor}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorVersion" + } + ]; + + // Required. The processor version to be created. + ProcessorVersion processor_version = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The schema the processor version will be trained with. + DocumentSchema document_schema = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The input data used to train the `ProcessorVersion`. + InputData input_data = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The processor version to use as a base for training. This processor version + // must be a child of `parent`. Format: + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`. + string base_processor_version = 8 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for the TrainProcessorVersion method. +message TrainProcessorVersionResponse { + // The resource name of the processor version produced by training. + string processor_version = 1; +} + +// The metadata that represents a processor version being created. +message TrainProcessorVersionMetadata { + // The dataset validation information. + // This includes any and all errors with documents and the dataset. + message DatasetValidation { + // The total number of document errors. + int32 document_error_count = 3; + + // The total number of dataset errors. + int32 dataset_error_count = 4; + + // Error information pertaining to specific documents. A maximum of 10 + // document errors will be returned. + // Any document with errors will not be used throughout training. + repeated google.rpc.Status document_errors = 1; + + // Error information for the dataset as a whole. A maximum of 10 dataset + // errors will be returned. + // A single dataset error is terminal for training. + repeated google.rpc.Status dataset_errors = 2; + } + + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; + + // The training dataset validation information. + DatasetValidation training_dataset_validation = 2; + + // The test dataset validation information. + DatasetValidation test_dataset_validation = 3; +} + +// Request message for review document method. +message ReviewDocumentRequest { + // The priority level of the human review task. + enum Priority { + // The default priority level. + DEFAULT = 0; + + // The urgent priority level. The labeling manager should allocate labeler + // resource to the urgent task queue to respect this priority level. + URGENT = 1; + } + + // The document payload. + oneof source { + // An inline document proto. + Document inline_document = 4; + } + + // Required. The resource name of the HumanReviewConfig that the document will be + // reviewed with. + string human_review_config = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/HumanReviewConfig" + } + ]; + + // 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; + + // The document schema of the human review task. + DocumentSchema document_schema = 6; +} + +// Response message for review document method. +message ReviewDocumentResponse { + // Possible states of the review operation. + enum State { + // The default value. This value is used if the state is omitted. + STATE_UNSPECIFIED = 0; + + // The review operation is rejected by the reviewer. + REJECTED = 1; + + // The review operation is succeeded. + SUCCEEDED = 2; + } + + // The Cloud Storage uri for the human reviewed document if the review is + // succeeded. + string gcs_destination = 1; + + // The state of the review operation. + State state = 2; + + // The reason why the review is rejected by reviewer. + string rejection_reason = 3; +} + +// The long running operation metadata for review document method. +message ReviewDocumentOperationMetadata { + // 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; + + // The Crowd Compute question ID. + string question_id = 6; +} + +// Evaluates the given ProcessorVersion against the supplied documents. +message EvaluateProcessorVersionRequest { + // Required. The resource name of the [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion] to evaluate. + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + string processor_version = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; + + // Optional. The documents used in the evaluation. If unspecified, use the processor's + // dataset as evaluation input. + BatchDocumentsInputConfig evaluation_documents = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Metadata of the EvaluateProcessorVersion method. +message EvaluateProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Metadata of the EvaluateProcessorVersion method. +message EvaluateProcessorVersionResponse { + // The resource name of the created evaluation. + string evaluation = 2; +} + +// Retrieves a specific Evaluation. +message GetEvaluationRequest { + // Required. The resource name of the [Evaluation][google.cloud.documentai.v1beta3.Evaluation] to get. + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Evaluation" + } + ]; +} + +// Retrieves a list of evaluations for a given ProcessorVersion. +message ListEvaluationsRequest { + // Required. The resource name of the [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion] to list evaluations for. + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; + + // The standard list page size. + // If unspecified, at most 5 evaluations will be returned. + // The maximum value is 100; values above 100 will be coerced to 100. + int32 page_size = 2; + + // A page token, received from a previous `ListEvaluations` call. + // Provide this to retrieve the subsequent page. + string page_token = 3; +} + +// The response from ListEvaluations. +message ListEvaluationsResponse { + // The evaluations requested. + repeated Evaluation evaluations = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_schema.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_schema.proto new file mode 100644 index 00000000000..1e29f7c89d9 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_schema.proto @@ -0,0 +1,141 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +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 = "DocumentAiDocumentSchema"; +option java_package = "com.google.cloud.documentai.v1beta3"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; + +// The schema defines the output of the processed document by a processor. +message DocumentSchema { + // EntityType is the wrapper of a label of the corresponding model with + // detailed attributes and limitations for entity-based processors. Multiple + // types can also compose a dependency tree to represent nested types. + message EntityType { + // Defines the a list of enum values. + message EnumValues { + // The individual values that this enum values type can include. + repeated string values = 1; + } + + // Defines properties that can be part of the entity type. + message Property { + // Types of occurrences of the entity type in the document. Note: this + // represents the number of instances of an entity types, not number of + // mentions of a given entity instance. + enum OccurrenceType { + // Unspecified occurrence type. + OCCURRENCE_TYPE_UNSPECIFIED = 0; + + // There will be zero or one instance of this entity type. + OPTIONAL_ONCE = 1; + + // The entity type will appear zero or multiple times. + OPTIONAL_MULTIPLE = 2; + + // The entity type will only appear exactly once. + REQUIRED_ONCE = 3; + + // The entity type will appear once or more times. + REQUIRED_MULTIPLE = 4; + } + + // The name of the property. Follows the same guidelines as the + // EntityType name. + string name = 1; + + // A reference to the value type of the property. This type is subject + // to the same conventions as the `Entity.base_types` field. + string value_type = 2; + + // Occurrence type limits the number of instances an entity type appears + // in the document. + OccurrenceType occurrence_type = 3; + } + + oneof value_source { + // If specified, lists all the possible values for this entity. This + // should not be more than a handful of values. If the number of values + // is >10 or could change frequently use the `EntityType.value_ontology` + // field and specify a list of all possible values in a value ontology + // file. + EnumValues enum_values = 14; + } + + // User defined name for the type. + string display_name = 13; + + // Name of the type. It must be unique within the schema file and + // cannot be a 'Common Type'. Besides that we use the following naming + // conventions: + // + // - *use `snake_casing`* + // - name matching is case-insensitive + // - Maximum 64 characters. + // - Must start with a letter. + // - Allowed characters: ASCII letters `[a-z0-9_-]`. (For backward + // compatibility internal infrastructure and tooling can handle any ascii + // character) + // - The `/` is sometimes used to denote a property of a type. For example + // `line_item/amount`. This convention is deprecated, but will still be + // honored for backward compatibility. + string name = 1; + + // The entity type that this type is derived from. For now, one and only + // one should be set. + repeated string base_types = 2; + + // Describing the nested structure, or composition of an entity. + repeated Property properties = 6; + } + + // Metadata for global schema behavior. + message Metadata { + // If true, a `document` entity type can be applied to subdocument ( + // splitting). Otherwise, it can only be applied to the entire document + // (classification). + bool document_splitter = 1; + + // If true, on a given page, there can be multiple `document` annotations + // covering it. + bool document_allow_multiple_labels = 2; + + // If set, all the nested entities must be prefixed with the parents. + bool prefixed_naming_on_properties = 6; + + // If set, we will skip the naming format validation in the schema. So the + // string values in `DocumentSchema.EntityType.name` and + // `DocumentSchema.EntityType.Property.name` will not be checked. + bool skip_naming_validation = 7; + } + + // Display name to show to users. + string display_name = 1; + + // Description of the schema. + string description = 2; + + // Entity types of the schema. + repeated EntityType entity_types = 3; + + // Metadata of the schema. + Metadata metadata = 4; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/evaluation.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/evaluation.proto new file mode 100644 index 00000000000..c6aa30e7ab4 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/evaluation.proto @@ -0,0 +1,164 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT 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/protobuf/timestamp.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 = "DocumentAiEvaluation"; +option java_package = "com.google.cloud.documentai.v1beta3"; +option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; +option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; + +// An evaluation of a ProcessorVersion's performance. +message Evaluation { + option (google.api.resource) = { + type: "documentai.googleapis.com/Evaluation" + pattern: "projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation}" + }; + + // Evaluation counters for the documents that were used. + message Counters { + // How many documents were sent for evaluation. + int32 input_documents_count = 1; + + // How many documents were not included in the evaluation as they didn't + // pass validation. + int32 invalid_documents_count = 2; + + // How many documents were not included in the evaluation as Document AI + // failed to process them. + int32 failed_documents_count = 3; + + // How many documents were used in the evaluation. + int32 evaluated_documents_count = 4; + } + + // Evaluation metrics, either in aggregate or about a specific entity. + message Metrics { + // The calculated precision. + float precision = 1; + + // The calculated recall. + float recall = 2; + + // The calculated f1 score. + float f1_score = 3; + + // The amount of occurrences in predicted documents. + int32 predicted_occurrences_count = 4; + + // The amount of occurrences in ground truth documents. + int32 ground_truth_occurrences_count = 5; + + // The amount of documents with a predicted occurrence. + int32 predicted_document_count = 10; + + // The amount of documents with a ground truth occurrence. + int32 ground_truth_document_count = 11; + + // The amount of true positives. + int32 true_positives_count = 6; + + // The amount of false positives. + int32 false_positives_count = 7; + + // The amount of false negatives. + int32 false_negatives_count = 8; + + // The amount of documents that had an occurrence of this label. + int32 total_documents_count = 9; + } + + // Evaluations metrics, at a specific confidence level. + message ConfidenceLevelMetrics { + // The confidence level. + float confidence_level = 1; + + // The metrics at the specific confidence level. + Metrics metrics = 2; + } + + // Metrics across multiple confidence levels. + message MultiConfidenceMetrics { + // A type that determines how metrics should be interpreted. + enum MetricsType { + // The metrics type is unspecified. By default, metrics without a + // particular specification are for leaf entity types (i.e., top-level + // entity types without child types, or child types which are not + // parent types themselves). + METRICS_TYPE_UNSPECIFIED = 0; + + // Indicates whether metrics for this particular label type represent an + // aggregate of metrics for other types instead of being based on actual + // TP/FP/FN values for the label type. Metrics for parent (i.e., non-leaf) + // entity types are an aggregate of metrics for their children. + AGGREGATE = 1; + } + + // Metrics across confidence levels with fuzzy matching enabled. + repeated ConfidenceLevelMetrics confidence_level_metrics = 1; + + // Metrics across confidence levels with only exact matching. + repeated ConfidenceLevelMetrics confidence_level_metrics_exact = 4; + + // The calculated area under the precision recall curve (AUPRC), computed by + // integrating over all confidence thresholds. + float auprc = 2; + + // The Estimated Calibration Error (ECE) of the confidence of the predicted + // entities. + float estimated_calibration_error = 3; + + // The AUPRC for metrics with fuzzy matching disabled, i.e., exact matching + // only. + float auprc_exact = 5; + + // The ECE for the predicted entities with fuzzy matching disabled, i.e., + // exact matching only. + float estimated_calibration_error_exact = 6; + + // The metrics type for the label. + MetricsType metrics_type = 7; + } + + // The resource name of the evaluation. + // Format: + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation}` + string name = 1; + + // The time that the evaluation was created. + google.protobuf.Timestamp create_time = 2; + + // Counters for the documents used in the evaluation. + Counters document_counters = 5; + + // Metrics for all the entities in aggregate. + MultiConfidenceMetrics all_entities_metrics = 3; + + // Metrics across confidence levels, for different entities. + map entity_metrics = 4; + + // The KMS key name used for encryption. + string kms_key_name = 6; + + // The KMS key version with which data is encrypted. + string kms_key_version_name = 7; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto new file mode 100644 index 00000000000..c42e0cb7a07 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +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/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto new file mode 100644 index 00000000000..cd573a823c4 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +import "google/protobuf/timestamp.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; + + // A related resource to this operation. + string resource = 5; + + // The creation time of the operation. + google.protobuf.Timestamp create_time = 3; + + // The last update time of the operation. + google.protobuf.Timestamp update_time = 4; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto new file mode 100644 index 00000000000..db13e89defa --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto @@ -0,0 +1,189 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/documentai/v1beta3/document_schema.proto"; +import "google/protobuf/timestamp.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"; + +// A processor version is an implementation of a processor. Each processor +// can have multiple versions, pre-trained by Google internally or up-trained +// by the customer. At a time, a processor can only have one default version +// version. So the processor's behavior (when processing documents) is defined +// by a default version +message ProcessorVersion { + option (google.api.resource) = { + type: "documentai.googleapis.com/ProcessorVersion" + pattern: "projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}" + }; + + // Information about the upcoming deprecation of this processor version. + message DeprecationInfo { + // The time at which this processor version will be deprecated. + google.protobuf.Timestamp deprecation_time = 1; + + // If set, the processor version that will be used as a replacement. + string replacement_processor_version = 2 [(google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + }]; + } + + // The possible states of the processor version. + enum State { + // The processor version is in an unspecified state. + STATE_UNSPECIFIED = 0; + + // The processor version is deployed and can be used for processing. + DEPLOYED = 1; + + // The processor version is being deployed. + DEPLOYING = 2; + + // The processor version is not deployed and cannot be used for processing. + UNDEPLOYED = 3; + + // The processor version is being undeployed. + UNDEPLOYING = 4; + + // The processor version is being created. + CREATING = 5; + + // The processor version is being deleted. + DELETING = 6; + + // The processor version failed and is in an indeterminate state. + FAILED = 7; + } + + // The resource name of the processor version. + // Format: + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}` + string name = 1; + + // The display name of the processor version. + string display_name = 2; + + // The schema of the processor version. Describes the output. + DocumentSchema document_schema = 12; + + // The state of the processor version. + State state = 6; + + // The time the processor version was created. + google.protobuf.Timestamp create_time = 7; + + // The KMS key name used for encryption. + string kms_key_name = 9; + + // The KMS key version with which data is encrypted. + string kms_key_version_name = 10; + + // Denotes that this ProcessorVersion is managed by google. + bool google_managed = 11; + + // If set, information about the eventual deprecation of this version. + DeprecationInfo deprecation_info = 13; +} + +// The first-class citizen for Document AI. Each processor defines how to +// extract structural information from a document. +message Processor { + option (google.api.resource) = { + type: "documentai.googleapis.com/Processor" + pattern: "projects/{project}/locations/{location}/processors/{processor}" + }; + + // The possible states of the processor. + enum State { + // The processor is in an unspecified state. + STATE_UNSPECIFIED = 0; + + // The processor is enabled, i.e., has an enabled version which can + // currently serve processing requests and all the feature dependencies have + // been successfully initialized. + ENABLED = 1; + + // The processor is disabled. + DISABLED = 2; + + // The processor is being enabled, will become `ENABLED` if successful. + ENABLING = 3; + + // The processor is being disabled, will become `DISABLED` if successful. + DISABLING = 4; + + // The processor is being created, will become either `ENABLED` (for + // successful creation) or `FAILED` (for failed ones). + // Once a processor is in this state, it can then be used for document + // processing, but the feature dependencies of the processor might not be + // fully created yet. + CREATING = 5; + + // The processor failed during creation or initialization of feature + // dependencies. The user should delete the processor and recreate one as + // all the functionalities of the processor are disabled. + FAILED = 6; + + // The processor is being deleted, will be removed if successful. + DELETING = 7; + } + + // Output only. Immutable. The resource name of the processor. + // Format: `projects/{project}/locations/{location}/processors/{processor}` + string name = 1 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. + // To get a list of processors types, see + // [FetchProcessorTypes][google.cloud.documentai.v1beta3.DocumentProcessorService.FetchProcessorTypes]. + string type = 2; + + // The display name of the processor. + string display_name = 3; + + // Output only. The state of the processor. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The default processor version. + string default_processor_version = 9 [(google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + }]; + + // Output only. Immutable. The http endpoint that can be called to invoke processing. + string process_endpoint = 6 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.field_behavior) = IMMUTABLE + ]; + + // The time the processor was created. + google.protobuf.Timestamp create_time = 7; + + // The KMS key used for encryption/decryption in CMEK scenarios. + // See https://cloud.google.com/security-key-management. + string kms_key_name = 8; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto new file mode 100644 index 00000000000..9afbf04d481 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.documentai.v1beta3; + +import "google/api/launch_stage.proto"; +import "google/api/resource.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, currently must be one of [us, eu]. + string location_id = 1; + } + + // The resource name of the processor type. + // Format: `projects/{project}/processorTypes/{processor_type}` + string name = 1; + + // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. + string type = 2; + + // The processor category, used by UI to group processor types. + string category = 3; + + // The locations in which this processor is available. + repeated LocationInfo available_locations = 4; + + // Whether the processor type allows creation. If true, users can create a + // processor of this processor type. Otherwise, users need to request access. + bool allow_creation = 6; + + // Launch stage of the processor type + google.api.LaunchStage launch_stage = 8; +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.batch_process_documents.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.batch_process_documents.js new file mode 100644 index 00000000000..25bd5f659c2 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.batch_process_documents.js @@ -0,0 +1,87 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of Processor google.cloud.documentai.v1beta3.Processor or + * ProcessorVersion google.cloud.documentai.v1beta3.ProcessorVersion. + * Format: `projects/{project}/locations/{location}/processors/{processor}`, + * or + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + */ + // const name = 'abc123' + /** + * The input config for each single document in the batch process. + */ + // const inputConfigs = 1234 + /** + * The overall output config for batch process. + */ + // const outputConfig = {} + /** + * The input documents for batch process. + */ + // const inputDocuments = {} + /** + * The overall output config for batch process. + */ + // const documentOutputConfig = {} + /** + * Whether Human Review feature should be skipped for this request. Default to + * false. + */ + // const skipHumanReview = true + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callBatchProcessDocuments() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.batchProcessDocuments(request); + const [response] = await operation.promise(); + console.log(response); + } + + callBatchProcessDocuments(); + // [END documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.create_processor.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.create_processor.js new file mode 100644 index 00000000000..fc1916f0a92 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.create_processor.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, processor) { + // [START documentai_v1beta3_generated_DocumentProcessorService_CreateProcessor_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent (project and location) under which to create the processor. + * Format: `projects/{project}/locations/{location}` + */ + // const parent = 'abc123' + /** + * 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. + */ + // const processor = {} + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callCreateProcessor() { + // Construct request + const request = { + parent, + processor, + }; + + // Run request + const response = await documentaiClient.createProcessor(request); + console.log(response); + } + + callCreateProcessor(); + // [END documentai_v1beta3_generated_DocumentProcessorService_CreateProcessor_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor.js new file mode 100644 index 00000000000..ae5e7227c34 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor resource name to be deleted. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callDeleteProcessor() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.deleteProcessor(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteProcessor(); + // [END documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor_version.js new file mode 100644 index 00000000000..a2c34c8befc --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor_version.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor version resource name to be deleted. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callDeleteProcessorVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.deleteProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteProcessorVersion(); + // [END documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.deploy_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.deploy_processor_version.js new file mode 100644 index 00000000000..416d46b66b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.deploy_processor_version.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_DeployProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor version resource name to be deployed. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callDeployProcessorVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.deployProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeployProcessorVersion(); + // [END documentai_v1beta3_generated_DocumentProcessorService_DeployProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.disable_processor.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.disable_processor.js new file mode 100644 index 00000000000..2fa77f79000 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.disable_processor.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor resource name to be disabled. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callDisableProcessor() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.disableProcessor(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDisableProcessor(); + // [END documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.enable_processor.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.enable_processor.js new file mode 100644 index 00000000000..e2ee9079f41 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.enable_processor.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor resource name to be enabled. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callEnableProcessor() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.enableProcessor(request); + const [response] = await operation.promise(); + console.log(response); + } + + callEnableProcessor(); + // [END documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js new file mode 100644 index 00000000000..e6af3689920 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(processorVersion) { + // [START documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ProcessorVersion google.cloud.documentai.v1beta3.ProcessorVersion to evaluate. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + */ + // const processorVersion = 'abc123' + /** + * Optional. The documents used in the evaluation. If unspecified, use the processor's + * dataset as evaluation input. + */ + // const evaluationDocuments = {} + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callEvaluateProcessorVersion() { + // Construct request + const request = { + processorVersion, + }; + + // Run request + const [operation] = await documentaiClient.evaluateProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callEvaluateProcessorVersion(); + // [END documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js new file mode 100644 index 00000000000..4fc8c1275e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START documentai_v1beta3_generated_DocumentProcessorService_FetchProcessorTypes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + */ + // const parent = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callFetchProcessorTypes() { + // Construct request + const request = { + parent, + }; + + // Run request + const response = await documentaiClient.fetchProcessorTypes(request); + console.log(response); + } + + callFetchProcessorTypes(); + // [END documentai_v1beta3_generated_DocumentProcessorService_FetchProcessorTypes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_evaluation.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_evaluation.js new file mode 100644 index 00000000000..7414abc0a9d --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_evaluation.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_GetEvaluation_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Evaluation google.cloud.documentai.v1beta3.Evaluation to get. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}` + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callGetEvaluation() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await documentaiClient.getEvaluation(request); + console.log(response); + } + + callGetEvaluation(); + // [END documentai_v1beta3_generated_DocumentProcessorService_GetEvaluation_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor.js new file mode 100644 index 00000000000..4b89803a0c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_GetProcessor_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor resource name. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callGetProcessor() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await documentaiClient.getProcessor(request); + console.log(response); + } + + callGetProcessor(); + // [END documentai_v1beta3_generated_DocumentProcessorService_GetProcessor_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor_version.js new file mode 100644 index 00000000000..9c30f2d02fd --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor_version.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_GetProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor resource name. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callGetProcessorVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await documentaiClient.getProcessorVersion(request); + console.log(response); + } + + callGetProcessorVersion(); + // [END documentai_v1beta3_generated_DocumentProcessorService_GetProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_evaluations.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_evaluations.js new file mode 100644 index 00000000000..05b206dc802 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_evaluations.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START documentai_v1beta3_generated_DocumentProcessorService_ListEvaluations_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the ProcessorVersion google.cloud.documentai.v1beta3.ProcessorVersion to list evaluations for. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + */ + // const parent = 'abc123' + /** + * The standard list page size. + * If unspecified, at most 5 evaluations will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + */ + // const pageSize = 1234 + /** + * A page token, received from a previous `ListEvaluations` call. + * Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callListEvaluations() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await documentaiClient.listEvaluationsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListEvaluations(); + // [END documentai_v1beta3_generated_DocumentProcessorService_ListEvaluations_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_types.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_types.js new file mode 100644 index 00000000000..7500d1d6dd7 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_types.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START documentai_v1beta3_generated_DocumentProcessorService_ListProcessorTypes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The location of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + */ + // const parent = 'abc123' + /** + * The maximum number of processor types to return. + * If unspecified, at most 100 processor types will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + */ + // const pageSize = 1234 + /** + * Used to retrieve the next page of results, empty if at the end of the list. + */ + // const pageToken = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callListProcessorTypes() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await documentaiClient.listProcessorTypesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProcessorTypes(); + // [END documentai_v1beta3_generated_DocumentProcessorService_ListProcessorTypes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_versions.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_versions.js new file mode 100644 index 00000000000..c922f46fadc --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_versions.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START documentai_v1beta3_generated_DocumentProcessorService_ListProcessorVersions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent (project, location and processor) to list all versions. + * Format: `projects/{project}/locations/{location}/processors/{processor}` + */ + // const parent = 'abc123' + /** + * The maximum number of processor versions to return. + * If unspecified, at most 10 processor versions will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + */ + // const pageSize = 1234 + /** + * We will return the processor versions sorted by creation time. The page + * token will point to the next processor version. + */ + // const pageToken = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callListProcessorVersions() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await documentaiClient.listProcessorVersionsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProcessorVersions(); + // [END documentai_v1beta3_generated_DocumentProcessorService_ListProcessorVersions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processors.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processors.js new file mode 100644 index 00000000000..c136a802329 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processors.js @@ -0,0 +1,75 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START documentai_v1beta3_generated_DocumentProcessorService_ListProcessors_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent (project and location) which owns this collection of Processors. + * Format: `projects/{project}/locations/{location}` + */ + // const parent = 'abc123' + /** + * 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. + */ + // const pageSize = 1234 + /** + * We will return the processors sorted by creation time. The page token + * will point to the next processor. + */ + // const pageToken = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callListProcessors() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await documentaiClient.listProcessorsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProcessors(); + // [END documentai_v1beta3_generated_DocumentProcessorService_ListProcessors_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.process_document.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.process_document.js new file mode 100644 index 00000000000..b64abecbc4c --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.process_document.js @@ -0,0 +1,89 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_ProcessDocument_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * An inline document proto. + */ + // const inlineDocument = {} + /** + * A raw document content (bytes). + */ + // const rawDocument = {} + /** + * Required. The resource name of the Processor google.cloud.documentai.v1beta3.Processor or + * ProcessorVersion google.cloud.documentai.v1beta3.ProcessorVersion + * to use for processing. If a Processor google.cloud.documentai.v1beta3.Processor is specified, the server will use + * its default version google.cloud.documentai.v1beta3.Processor.default_processor_version. Format: + * `projects/{project}/locations/{location}/processors/{processor}`, or + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + */ + // const name = 'abc123' + /** + * The document payload, the content and mime_type fields must be set. + */ + // const document = {} + /** + * Whether Human Review feature should be skipped for this request. Default to + * false. + */ + // const skipHumanReview = true + /** + * Specifies which fields to include in ProcessResponse's document. + * Only supports top level document and pages field so it must be in the form + * of `{document_field_name}` or `pages.{page_field_name}`. + */ + // const fieldMask = {} + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callProcessDocument() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await documentaiClient.processDocument(request); + console.log(response); + } + + callProcessDocument(); + // [END documentai_v1beta3_generated_DocumentProcessorService_ProcessDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.review_document.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.review_document.js new file mode 100644 index 00000000000..cb7b942ae57 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.review_document.js @@ -0,0 +1,83 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(humanReviewConfig) { + // [START documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * An inline document proto. + */ + // const inlineDocument = {} + /** + * Required. The resource name of the HumanReviewConfig that the document will be + * reviewed with. + */ + // const humanReviewConfig = 'abc123' + /** + * The document that needs human review. + */ + // const document = {} + /** + * Whether the validation should be performed on the ad-hoc review request. + */ + // const enableSchemaValidation = true + /** + * The priority of the human review task. + */ + // const priority = {} + /** + * The document schema of the human review task. + */ + // const documentSchema = {} + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callReviewDocument() { + // Construct request + const request = { + humanReviewConfig, + }; + + // Run request + const [operation] = await documentaiClient.reviewDocument(request); + const [response] = await operation.promise(); + console.log(response); + } + + callReviewDocument(); + // [END documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.set_default_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.set_default_processor_version.js new file mode 100644 index 00000000000..44d9177db6b --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.set_default_processor_version.js @@ -0,0 +1,69 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(processor, defaultProcessorVersion) { + // [START documentai_v1beta3_generated_DocumentProcessorService_SetDefaultProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Processor google.cloud.documentai.v1beta3.Processor to change default version. + */ + // const processor = 'abc123' + /** + * Required. The resource name of child ProcessorVersion google.cloud.documentai.v1beta3.ProcessorVersion to use as default. + * Format: + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` + */ + // const defaultProcessorVersion = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callSetDefaultProcessorVersion() { + // Construct request + const request = { + processor, + defaultProcessorVersion, + }; + + // Run request + const [operation] = await documentaiClient.setDefaultProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callSetDefaultProcessorVersion(); + // [END documentai_v1beta3_generated_DocumentProcessorService_SetDefaultProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.train_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.train_processor_version.js new file mode 100644 index 00000000000..24015f9da1a --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.train_processor_version.js @@ -0,0 +1,82 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, processorVersion) { + // [START documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent (project, location and processor) to create the new version for. + * Format: `projects/{project}/locations/{location}/processors/{processor}`. + */ + // const parent = 'abc123' + /** + * Required. The processor version to be created. + */ + // const processorVersion = {} + /** + * Optional. The schema the processor version will be trained with. + */ + // const documentSchema = {} + /** + * Optional. The input data used to train the `ProcessorVersion`. + */ + // const inputData = {} + /** + * Optional. The processor version to use as a base for training. This processor version + * must be a child of `parent`. Format: + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`. + */ + // const baseProcessorVersion = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callTrainProcessorVersion() { + // Construct request + const request = { + parent, + processorVersion, + }; + + // Run request + const [operation] = await documentaiClient.trainProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callTrainProcessorVersion(); + // [END documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js new file mode 100644 index 00000000000..6bc7a006fb6 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START documentai_v1beta3_generated_DocumentProcessorService_UndeployProcessorVersion_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The processor version resource name to be undeployed. + */ + // const name = 'abc123' + + // Imports the Documentai library + const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; + + // Instantiates a client + const documentaiClient = new DocumentProcessorServiceClient(); + + async function callUndeployProcessorVersion() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await documentaiClient.undeployProcessorVersion(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUndeployProcessorVersion(); + // [END documentai_v1beta3_generated_DocumentProcessorService_UndeployProcessorVersion_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json new file mode 100644 index 00000000000..96ed239b5ff --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json @@ -0,0 +1,975 @@ +{ + "clientLibrary": { + "name": "nodejs-documentai", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.documentai.v1beta3", + "version": "v1beta3" + } + ] + }, + "snippets": [ + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ProcessDocument_async", + "title": "DocumentProcessorService processDocument Sample", + "origin": "API_DEFINITION", + "description": " Processes a single document.", + "canonical": true, + "file": "document_processor_service.process_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 81, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ProcessDocument", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument", + "async": true, + "parameters": [ + { + "name": "inline_document", + "type": ".google.cloud.documentai.v1beta3.Document" + }, + { + "name": "raw_document", + "type": ".google.cloud.documentai.v1beta3.RawDocument" + }, + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "document", + "type": ".google.cloud.documentai.v1beta3.Document" + }, + { + "name": "skip_human_review", + "type": "TYPE_BOOL" + }, + { + "name": "field_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.ProcessResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ProcessDocument", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async", + "title": "DocumentProcessorService batchProcessDocuments Sample", + "origin": "API_DEFINITION", + "description": " LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.", + "canonical": true, + "file": "document_processor_service.batch_process_documents.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 79, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchProcessDocuments", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "input_configs", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "output_config", + "type": ".google.cloud.documentai.v1beta3.BatchProcessRequest.BatchOutputConfig" + }, + { + "name": "input_documents", + "type": ".google.cloud.documentai.v1beta3.BatchDocumentsInputConfig" + }, + { + "name": "document_output_config", + "type": ".google.cloud.documentai.v1beta3.DocumentOutputConfig" + }, + { + "name": "skip_human_review", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "BatchProcessDocuments", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_FetchProcessorTypes_async", + "title": "DocumentProcessorService fetchProcessorTypes Sample", + "origin": "API_DEFINITION", + "description": " Fetches processor types. Note that we do not use ListProcessorTypes here because it is not paginated.", + "canonical": true, + "file": "document_processor_service.fetch_processor_types.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "FetchProcessorTypes", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.FetchProcessorTypes", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.FetchProcessorTypesResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "FetchProcessorTypes", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.FetchProcessorTypes", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListProcessorTypes_async", + "title": "DocumentProcessorService listProcessorTypes Sample", + "origin": "API_DEFINITION", + "description": " Lists the processor types that exist.", + "canonical": true, + "file": "document_processor_service.list_processor_types.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProcessorTypes", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessorTypes", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.ListProcessorTypesResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ListProcessorTypes", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessorTypes", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListProcessors_async", + "title": "DocumentProcessorService listProcessors Sample", + "origin": "API_DEFINITION", + "description": " Lists all processors which belong to this project.", + "canonical": true, + "file": "document_processor_service.list_processors.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProcessors", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessors", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.ListProcessorsResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ListProcessors", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessors", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_GetProcessor_async", + "title": "DocumentProcessorService getProcessor Sample", + "origin": "API_DEFINITION", + "description": " Gets a processor detail.", + "canonical": true, + "file": "document_processor_service.get_processor.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProcessor", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetProcessor", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.Processor", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "GetProcessor", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetProcessor", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async", + "title": "DocumentProcessorService trainProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Trains a new processor version. Operation metadata is returned as cloud_documentai_core.TrainProcessorVersionMetadata.", + "canonical": true, + "file": "document_processor_service.train_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TrainProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.TrainProcessorVersion", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "processor_version", + "type": ".google.cloud.documentai.v1beta3.ProcessorVersion" + }, + { + "name": "document_schema", + "type": ".google.cloud.documentai.v1beta3.DocumentSchema" + }, + { + "name": "input_data", + "type": ".google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData" + }, + { + "name": "base_processor_version", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "TrainProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.TrainProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_GetProcessorVersion_async", + "title": "DocumentProcessorService getProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Gets a processor version detail.", + "canonical": true, + "file": "document_processor_service.get_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetProcessorVersion", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.ProcessorVersion", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "GetProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListProcessorVersions_async", + "title": "DocumentProcessorService listProcessorVersions Sample", + "origin": "API_DEFINITION", + "description": " Lists all versions of a processor.", + "canonical": true, + "file": "document_processor_service.list_processor_versions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProcessorVersions", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessorVersions", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.ListProcessorVersionsResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ListProcessorVersions", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessorVersions", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessorVersion_async", + "title": "DocumentProcessorService deleteProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Deletes the processor version, all artifacts under the processor version will be deleted.", + "canonical": true, + "file": "document_processor_service.delete_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeleteProcessorVersion", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "DeleteProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeleteProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DeployProcessorVersion_async", + "title": "DocumentProcessorService deployProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Deploys the processor version.", + "canonical": true, + "file": "document_processor_service.deploy_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeployProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeployProcessorVersion", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "DeployProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeployProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_UndeployProcessorVersion_async", + "title": "DocumentProcessorService undeployProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Undeploys the processor version.", + "canonical": true, + "file": "document_processor_service.undeploy_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UndeployProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.UndeployProcessorVersion", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "UndeployProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.UndeployProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_CreateProcessor_async", + "title": "DocumentProcessorService createProcessor Sample", + "origin": "API_DEFINITION", + "description": " Creates a processor from the type processor that the user chose. The processor will be at \"ENABLED\" state by default after its creation.", + "canonical": true, + "file": "document_processor_service.create_processor.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProcessor", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.CreateProcessor", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "processor", + "type": ".google.cloud.documentai.v1beta3.Processor" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.Processor", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "CreateProcessor", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.CreateProcessor", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async", + "title": "DocumentProcessorService deleteProcessor Sample", + "origin": "API_DEFINITION", + "description": " Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.", + "canonical": true, + "file": "document_processor_service.delete_processor.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProcessor", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeleteProcessor", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "DeleteProcessor", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeleteProcessor", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async", + "title": "DocumentProcessorService enableProcessor Sample", + "origin": "API_DEFINITION", + "description": " Enables a processor", + "canonical": true, + "file": "document_processor_service.enable_processor.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "EnableProcessor", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EnableProcessor", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "EnableProcessor", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EnableProcessor", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async", + "title": "DocumentProcessorService disableProcessor Sample", + "origin": "API_DEFINITION", + "description": " Disables a processor", + "canonical": true, + "file": "document_processor_service.disable_processor.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DisableProcessor", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DisableProcessor", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "DisableProcessor", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DisableProcessor", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_SetDefaultProcessorVersion_async", + "title": "DocumentProcessorService setDefaultProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Set the default (active) version of a [Processor][google.cloud.documentai.v1beta3.Processor] that will be used in [ProcessDocument][google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument] and [BatchProcessDocuments][google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments].", + "canonical": true, + "file": "document_processor_service.set_default_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetDefaultProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.SetDefaultProcessorVersion", + "async": true, + "parameters": [ + { + "name": "processor", + "type": "TYPE_STRING" + }, + { + "name": "default_processor_version", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "SetDefaultProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.SetDefaultProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async", + "title": "DocumentProcessorService reviewDocument Sample", + "origin": "API_DEFINITION", + "description": " Send a document for Human Review. The input document should be processed by the specified processor.", + "canonical": true, + "file": "document_processor_service.review_document.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReviewDocument", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ReviewDocument", + "async": true, + "parameters": [ + { + "name": "inline_document", + "type": ".google.cloud.documentai.v1beta3.Document" + }, + { + "name": "human_review_config", + "type": "TYPE_STRING" + }, + { + "name": "document", + "type": ".google.cloud.documentai.v1beta3.Document" + }, + { + "name": "enable_schema_validation", + "type": "TYPE_BOOL" + }, + { + "name": "priority", + "type": ".google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority" + }, + { + "name": "document_schema", + "type": ".google.cloud.documentai.v1beta3.DocumentSchema" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ReviewDocument", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ReviewDocument", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async", + "title": "DocumentProcessorService evaluateProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Evaluates a ProcessorVersion against annotated documents, producing an Evaluation.", + "canonical": true, + "file": "document_processor_service.evaluate_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "EvaluateProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EvaluateProcessorVersion", + "async": true, + "parameters": [ + { + "name": "processor_version", + "type": "TYPE_STRING" + }, + { + "name": "evaluation_documents", + "type": ".google.cloud.documentai.v1beta3.BatchDocumentsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "EvaluateProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EvaluateProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_GetEvaluation_async", + "title": "DocumentProcessorService getEvaluation Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a specific evaluation.", + "canonical": true, + "file": "document_processor_service.get_evaluation.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEvaluation", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetEvaluation", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.Evaluation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "GetEvaluation", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetEvaluation", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListEvaluations_async", + "title": "DocumentProcessorService listEvaluations Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a set of evaluations for a given processor version.", + "canonical": true, + "file": "document_processor_service.list_evaluations.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListEvaluations", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListEvaluations", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.ListEvaluationsResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ListEvaluations", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListEvaluations", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + } + ] +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/src/index.ts new file mode 100644 index 00000000000..1910b60fddc --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts new file mode 100644 index 00000000000..3d65687363a --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts @@ -0,0 +1,3321 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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'; +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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new DocumentProcessorServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + evaluationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation}' + ), + 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}' + ), + processorVersionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}' + ), + 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 = { + listProcessorTypes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processorTypes'), + listProcessors: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processors'), + listProcessorVersions: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processorVersions'), + listEvaluations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'evaluations') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta3/{name=projects/*/locations/*}',additional_bindings: [{get: '/uiv1beta3/{name=projects/*/locations/*}',}], + },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta3/{name=projects/*}/locations',additional_bindings: [{get: '/uiv1beta3/{name=projects/*}/locations',}], + },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta3/{name=projects/*/locations/*/operations/*}:cancel',additional_bindings: [{post: '/uiv1beta3/{name=projects/*/locations/*/operations/*}:cancel',}], + },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta3/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/uiv1beta3/{name=projects/*/locations/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta3/{name=projects/*/locations/*/operations}',additional_bindings: [{get: '/uiv1beta3/{name=projects/*/locations/*/operations}',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 trainProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.TrainProcessorVersionResponse') as gax.protobuf.Type; + const trainProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata') as gax.protobuf.Type; + const deleteProcessorVersionResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.DeleteProcessorVersionMetadata') as gax.protobuf.Type; + const deployProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.DeployProcessorVersionResponse') as gax.protobuf.Type; + const deployProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.DeployProcessorVersionMetadata') as gax.protobuf.Type; + const undeployProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.UndeployProcessorVersionResponse') as gax.protobuf.Type; + const undeployProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.UndeployProcessorVersionMetadata') 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 setDefaultProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionResponse') as gax.protobuf.Type; + const setDefaultProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionMetadata') 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; + const evaluateProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse') as gax.protobuf.Type; + const evaluateProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + batchProcessDocumentsResponse.decode.bind(batchProcessDocumentsResponse), + batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata)), + trainProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + trainProcessorVersionResponse.decode.bind(trainProcessorVersionResponse), + trainProcessorVersionMetadata.decode.bind(trainProcessorVersionMetadata)), + deleteProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteProcessorVersionResponse.decode.bind(deleteProcessorVersionResponse), + deleteProcessorVersionMetadata.decode.bind(deleteProcessorVersionMetadata)), + deployProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deployProcessorVersionResponse.decode.bind(deployProcessorVersionResponse), + deployProcessorVersionMetadata.decode.bind(deployProcessorVersionMetadata)), + undeployProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + undeployProcessorVersionResponse.decode.bind(undeployProcessorVersionResponse), + undeployProcessorVersionMetadata.decode.bind(undeployProcessorVersionMetadata)), + 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)), + setDefaultProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + setDefaultProcessorVersionResponse.decode.bind(setDefaultProcessorVersionResponse), + setDefaultProcessorVersionMetadata.decode.bind(setDefaultProcessorVersionMetadata)), + reviewDocument: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + reviewDocumentResponse.decode.bind(reviewDocumentResponse), + reviewDocumentMetadata.decode.bind(reviewDocumentMetadata)), + evaluateProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + evaluateProcessorVersionResponse.decode.bind(evaluateProcessorVersionResponse), + evaluateProcessorVersionMetadata.decode.bind(evaluateProcessorVersionMetadata)) + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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', 'listProcessorTypes', 'listProcessors', 'getProcessor', 'trainProcessorVersion', 'getProcessorVersion', 'listProcessorVersions', 'deleteProcessorVersion', 'deployProcessorVersion', 'undeployProcessorVersion', 'createProcessor', 'deleteProcessor', 'enableProcessor', 'disableProcessor', 'setDefaultProcessorVersion', 'reviewDocument', 'evaluateProcessorVersion', 'getEvaluation', 'listEvaluations']; + 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._opts.fallback + ); + + 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 -- + // ------------------- +/** + * 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 resource name of the {@link google.cloud.documentai.v1beta3.Processor|Processor} or + * {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} + * to use for processing. If a {@link google.cloud.documentai.v1beta3.Processor|Processor} is specified, the server will use + * its {@link google.cloud.documentai.v1beta3.Processor.default_processor_version|default version}. Format: + * `projects/{project}/locations/{location}/processors/{processor}`, or + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @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 {google.protobuf.FieldMask} request.fieldMask + * Specifies which fields to include in ProcessResponse's document. + * Only supports top level document and pages field so it must be in the form + * of `{document_field_name}` or `pages.{page_field_name}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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 include:samples/generated/v1beta3/document_processor_service.process_document.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ProcessDocument_async + */ + 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; + 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.processDocument(request, options, callback); + } +/** + * Fetches processor types. Note that we do not use ListProcessorTypes here + * because it is not paginated. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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 include:samples/generated/v1beta3/document_processor_service.fetch_processor_types.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_FetchProcessorTypes_async + */ + 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; + 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.fetchProcessorTypes(request, options, callback); + } +/** + * Gets a processor detail. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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 include:samples/generated/v1beta3/document_processor_service.get_processor.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_GetProcessor_async + */ + getProcessor( + request?: protos.google.cloud.documentai.v1beta3.IGetProcessorRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|undefined, {}|undefined + ]>; + getProcessor( + request: protos.google.cloud.documentai.v1beta3.IGetProcessorRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|null|undefined, + {}|null|undefined>): void; + getProcessor( + request: protos.google.cloud.documentai.v1beta3.IGetProcessorRequest, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|null|undefined, + {}|null|undefined>): void; + getProcessor( + request?: protos.google.cloud.documentai.v1beta3.IGetProcessorRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessor, + protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProcessor(request, options, callback); + } +/** + * Gets a processor version detail. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor resource name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ProcessorVersion]{@link google.cloud.documentai.v1beta3.ProcessorVersion}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.get_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_GetProcessorVersion_async + */ + getProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessorVersion, + protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|undefined, {}|undefined + ]>; + getProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IProcessorVersion, + protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|null|undefined, + {}|null|undefined>): void; + getProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IProcessorVersion, + protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|null|undefined, + {}|null|undefined>): void; + getProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1beta3.IProcessorVersion, + protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1beta3.IProcessorVersion, + protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessorVersion, + protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getProcessorVersion(request, options, callback); + } +/** + * 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 include:samples/generated/v1beta3/document_processor_service.create_processor.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_CreateProcessor_async + */ + 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; + 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createProcessor(request, options, callback); + } +/** + * Retrieves a specific evaluation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the {@link google.cloud.documentai.v1beta3.Evaluation|Evaluation} to get. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.get_evaluation.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_GetEvaluation_async + */ + getEvaluation( + request?: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta3.IEvaluation, + protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|undefined, {}|undefined + ]>; + getEvaluation( + request: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IEvaluation, + protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|null|undefined, + {}|null|undefined>): void; + getEvaluation( + request: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IEvaluation, + protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|null|undefined, + {}|null|undefined>): void; + getEvaluation( + request?: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.documentai.v1beta3.IEvaluation, + protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.documentai.v1beta3.IEvaluation, + protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.documentai.v1beta3.IEvaluation, + protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getEvaluation(request, options, callback); + } + +/** + * 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 resource name of {@link google.cloud.documentai.v1beta3.Processor|Processor} or + * {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion}. + * Format: `projects/{project}/locations/{location}/processors/{processor}`, + * or + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @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 include:samples/generated/v1beta3/document_processor_service.batch_process_documents.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async + */ + 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; + 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' + ] = this._gaxModule.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 include:samples/generated/v1beta3/document_processor_service.batch_process_documents.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async + */ + async checkBatchProcessDocumentsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Trains a new processor version. + * Operation metadata is returned as + * cloud_documentai_core.TrainProcessorVersionMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project, location and processor) to create the new version for. + * Format: `projects/{project}/locations/{location}/processors/{processor}`. + * @param {google.cloud.documentai.v1beta3.ProcessorVersion} request.processorVersion + * Required. The processor version to be created. + * @param {google.cloud.documentai.v1beta3.DocumentSchema} [request.documentSchema] + * Optional. The schema the processor version will be trained with. + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData} [request.inputData] + * Optional. The input data used to train the `ProcessorVersion`. + * @param {string} [request.baseProcessorVersion] + * Optional. The processor version to use as a base for training. This processor version + * must be a child of `parent`. Format: + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.train_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async + */ + trainProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + trainProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + trainProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + trainProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.trainProcessorVersion(request, options, callback); + } +/** + * Check the status of the long running operation returned by `trainProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.train_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async + */ + async checkTrainProcessorVersionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.trainProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes the processor version, all artifacts under the processor version + * will be deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor version 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 include:samples/generated/v1beta3/document_processor_service.delete_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessorVersion_async + */ + deleteProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteProcessorVersion(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.delete_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessorVersion_async + */ + async checkDeleteProcessorVersionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deploys the processor version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor version resource name to be deployed. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.deploy_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeployProcessorVersion_async + */ + deployProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deployProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deployProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deployProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deployProcessorVersion(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deployProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.deploy_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeployProcessorVersion_async + */ + async checkDeployProcessorVersionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deployProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Undeploys the processor version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The processor version resource name to be undeployed. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_UndeployProcessorVersion_async + */ + undeployProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IUndeployProcessorVersionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + undeployProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IUndeployProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeployProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IUndeployProcessorVersionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeployProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IUndeployProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.undeployProcessorVersion(request, options, callback); + } +/** + * Check the status of the long running operation returned by `undeployProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_UndeployProcessorVersion_async + */ + async checkUndeployProcessorVersionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.undeployProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * 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 include:samples/generated/v1beta3/document_processor_service.delete_processor.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async + */ + 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; + 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' + ] = this._gaxModule.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 include:samples/generated/v1beta3/document_processor_service.delete_processor.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async + */ + async checkDeleteProcessorProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteProcessor, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * 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 include:samples/generated/v1beta3/document_processor_service.enable_processor.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async + */ + 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; + 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' + ] = this._gaxModule.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 include:samples/generated/v1beta3/document_processor_service.enable_processor.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async + */ + async checkEnableProcessorProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.enableProcessor, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * 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 include:samples/generated/v1beta3/document_processor_service.disable_processor.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async + */ + 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; + 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' + ] = this._gaxModule.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 include:samples/generated/v1beta3/document_processor_service.disable_processor.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async + */ + async checkDisableProcessorProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.disableProcessor, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Set the default (active) version of a {@link google.cloud.documentai.v1beta3.Processor|Processor} that will be used in + * {@link google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument|ProcessDocument} and + * {@link google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments|BatchProcessDocuments}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.processor + * Required. The resource name of the {@link google.cloud.documentai.v1beta3.Processor|Processor} to change default version. + * @param {string} request.defaultProcessorVersion + * Required. The resource name of child {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to use as default. + * Format: + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.set_default_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_SetDefaultProcessorVersion_async + */ + setDefaultProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.ISetDefaultProcessorVersionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + setDefaultProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.ISetDefaultProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setDefaultProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.ISetDefaultProcessorVersionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + setDefaultProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.ISetDefaultProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'processor': request.processor ?? '', + }); + this.initialize(); + return this.innerApiCalls.setDefaultProcessorVersion(request, options, callback); + } +/** + * Check the status of the long running operation returned by `setDefaultProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.set_default_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_SetDefaultProcessorVersion_async + */ + async checkSetDefaultProcessorVersionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.setDefaultProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * 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 {google.cloud.documentai.v1beta3.DocumentSchema} request.documentSchema + * The document schema 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 include:samples/generated/v1beta3/document_processor_service.review_document.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async + */ + 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; + 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' + ] = this._gaxModule.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 include:samples/generated/v1beta3/document_processor_service.review_document.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async + */ + async checkReviewDocumentProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.reviewDocument, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Evaluates a ProcessorVersion against annotated documents, producing an + * Evaluation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.processorVersion + * Required. The resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to evaluate. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @param {google.cloud.documentai.v1beta3.BatchDocumentsInputConfig} [request.evaluationDocuments] + * Optional. The documents used in the evaluation. If unspecified, use the processor's + * dataset as evaluation input. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async + */ + evaluateProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + evaluateProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + evaluateProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + evaluateProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'processor_version': request.processorVersion ?? '', + }); + this.initialize(); + return this.innerApiCalls.evaluateProcessorVersion(request, options, callback); + } +/** + * Check the status of the long running operation returned by `evaluateProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async + */ + async checkEvaluateProcessorVersionProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.evaluateProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists the processor types that exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + * @param {number} request.pageSize + * The maximum number of processor types to return. + * If unspecified, at most 100 processor types will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + * @param {string} request.pageToken + * Used to retrieve the next page of results, empty if at the end of the list. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ProcessorType]{@link google.cloud.documentai.v1beta3.ProcessorType}. + * 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 `listProcessorTypesAsync()` + * 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. + */ + listProcessorTypes( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessorType[], + protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest|null, + protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse + ]>; + listProcessorTypes( + request: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessorType>): void; + listProcessorTypes( + request: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, + callback: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessorType>): void; + listProcessorTypes( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessorType>, + callback?: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessorType>): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessorType[], + protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest|null, + protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProcessorTypes(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 location of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + * @param {number} request.pageSize + * The maximum number of processor types to return. + * If unspecified, at most 100 processor types will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + * @param {string} request.pageToken + * Used to retrieve the next page of results, empty if at the end of the list. + * @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 [ProcessorType]{@link google.cloud.documentai.v1beta3.ProcessorType} 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 `listProcessorTypesAsync()` + * 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. + */ + listProcessorTypesStream( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessorTypes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessorTypes.createStream( + this.innerApiCalls.listProcessorTypes as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProcessorTypes`, 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 location of processor type to list. + * The available processor types may depend on the allow-listing on projects. + * Format: `projects/{project}/locations/{location}` + * @param {number} request.pageSize + * The maximum number of processor types to return. + * If unspecified, at most 100 processor types will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + * @param {string} request.pageToken + * Used to retrieve the next page of results, empty if at the end of the list. + * @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 + * [ProcessorType]{@link google.cloud.documentai.v1beta3.ProcessorType}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.list_processor_types.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ListProcessorTypes_async + */ + listProcessorTypesAsync( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessorTypes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessorTypes.asyncIterate( + this.innerApiCalls['listProcessorTypes'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * 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, + 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; + 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' + ] = this._gaxModule.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessors']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessors.createStream( + this.innerApiCalls.listProcessors as 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 include:samples/generated/v1beta3/document_processor_service.list_processors.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ListProcessors_async + */ + 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessors']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessors.asyncIterate( + this.innerApiCalls['listProcessors'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Lists all versions of a processor. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project, location and processor) to list all versions. + * Format: `projects/{project}/locations/{location}/processors/{processor}` + * @param {number} request.pageSize + * The maximum number of processor versions to return. + * If unspecified, at most 10 processor versions will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * We will return the processor versions sorted by creation time. The page + * token will point to the next processor version. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ProcessorVersion]{@link google.cloud.documentai.v1beta3.ProcessorVersion}. + * 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 `listProcessorVersionsAsync()` + * 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. + */ + listProcessorVersions( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessorVersion[], + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest|null, + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse + ]>; + listProcessorVersions( + request: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessorVersion>): void; + listProcessorVersions( + request: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessorVersion>): void; + listProcessorVersions( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessorVersion>, + callback?: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IProcessorVersion>): + Promise<[ + protos.google.cloud.documentai.v1beta3.IProcessorVersion[], + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest|null, + protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProcessorVersions(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, location and processor) to list all versions. + * Format: `projects/{project}/locations/{location}/processors/{processor}` + * @param {number} request.pageSize + * The maximum number of processor versions to return. + * If unspecified, at most 10 processor versions will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * We will return the processor versions sorted by creation time. The page + * token will point to the next processor version. + * @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 [ProcessorVersion]{@link google.cloud.documentai.v1beta3.ProcessorVersion} 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 `listProcessorVersionsAsync()` + * 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. + */ + listProcessorVersionsStream( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessorVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessorVersions.createStream( + this.innerApiCalls.listProcessorVersions as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProcessorVersions`, 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, location and processor) to list all versions. + * Format: `projects/{project}/locations/{location}/processors/{processor}` + * @param {number} request.pageSize + * The maximum number of processor versions to return. + * If unspecified, at most 10 processor versions will be returned. + * The maximum value is 20; values above 20 will be coerced to 20. + * @param {string} request.pageToken + * We will return the processor versions sorted by creation time. The page + * token will point to the next processor version. + * @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 + * [ProcessorVersion]{@link google.cloud.documentai.v1beta3.ProcessorVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.list_processor_versions.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ListProcessorVersions_async + */ + listProcessorVersionsAsync( + request?: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProcessorVersions']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProcessorVersions.asyncIterate( + this.innerApiCalls['listProcessorVersions'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** + * Retrieves a set of evaluations for a given processor version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to list evaluations for. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @param {number} request.pageSize + * The standard list page size. + * If unspecified, at most 5 evaluations will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous `ListEvaluations` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation}. + * 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 `listEvaluationsAsync()` + * 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. + */ + listEvaluations( + request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.documentai.v1beta3.IEvaluation[], + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest|null, + protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse + ]>; + listEvaluations( + request: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IEvaluation>): void; + listEvaluations( + request: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + callback: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IEvaluation>): void; + listEvaluations( + request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IEvaluation>, + callback?: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse|null|undefined, + protos.google.cloud.documentai.v1beta3.IEvaluation>): + Promise<[ + protos.google.cloud.documentai.v1beta3.IEvaluation[], + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest|null, + protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listEvaluations(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 resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to list evaluations for. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @param {number} request.pageSize + * The standard list page size. + * If unspecified, at most 5 evaluations will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous `ListEvaluations` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation} 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 `listEvaluationsAsync()` + * 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. + */ + listEvaluationsStream( + request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listEvaluations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEvaluations.createStream( + this.innerApiCalls.listEvaluations as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listEvaluations`, 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 resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to list evaluations for. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @param {number} request.pageSize + * The standard list page size. + * If unspecified, at most 5 evaluations will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous `ListEvaluations` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.list_evaluations.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ListEvaluations_async + */ + listEvaluationsAsync( + request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listEvaluations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEvaluations.asyncIterate( + this.innerApiCalls['listEvaluations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified evaluation resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} processor + * @param {string} processor_version + * @param {string} evaluation + * @returns {string} Resource name string. + */ + evaluationPath(project:string,location:string,processor:string,processorVersion:string,evaluation:string) { + return this.pathTemplates.evaluationPathTemplate.render({ + project: project, + location: location, + processor: processor, + processor_version: processorVersion, + evaluation: evaluation, + }); + } + + /** + * Parse the project from Evaluation resource. + * + * @param {string} evaluationName + * A fully-qualified path representing Evaluation resource. + * @returns {string} A string representing the project. + */ + matchProjectFromEvaluationName(evaluationName: string) { + return this.pathTemplates.evaluationPathTemplate.match(evaluationName).project; + } + + /** + * Parse the location from Evaluation resource. + * + * @param {string} evaluationName + * A fully-qualified path representing Evaluation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromEvaluationName(evaluationName: string) { + return this.pathTemplates.evaluationPathTemplate.match(evaluationName).location; + } + + /** + * Parse the processor from Evaluation resource. + * + * @param {string} evaluationName + * A fully-qualified path representing Evaluation resource. + * @returns {string} A string representing the processor. + */ + matchProcessorFromEvaluationName(evaluationName: string) { + return this.pathTemplates.evaluationPathTemplate.match(evaluationName).processor; + } + + /** + * Parse the processor_version from Evaluation resource. + * + * @param {string} evaluationName + * A fully-qualified path representing Evaluation resource. + * @returns {string} A string representing the processor_version. + */ + matchProcessorVersionFromEvaluationName(evaluationName: string) { + return this.pathTemplates.evaluationPathTemplate.match(evaluationName).processor_version; + } + + /** + * Parse the evaluation from Evaluation resource. + * + * @param {string} evaluationName + * A fully-qualified path representing Evaluation resource. + * @returns {string} A string representing the evaluation. + */ + matchEvaluationFromEvaluationName(evaluationName: string) { + return this.pathTemplates.evaluationPathTemplate.match(evaluationName).evaluation; + } + + /** + * 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 processorVersion resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} processor + * @param {string} processor_version + * @returns {string} Resource name string. + */ + processorVersionPath(project:string,location:string,processor:string,processorVersion:string) { + return this.pathTemplates.processorVersionPathTemplate.render({ + project: project, + location: location, + processor: processor, + processor_version: processorVersion, + }); + } + + /** + * Parse the project from ProcessorVersion resource. + * + * @param {string} processorVersionName + * A fully-qualified path representing ProcessorVersion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProcessorVersionName(processorVersionName: string) { + return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).project; + } + + /** + * Parse the location from ProcessorVersion resource. + * + * @param {string} processorVersionName + * A fully-qualified path representing ProcessorVersion resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProcessorVersionName(processorVersionName: string) { + return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).location; + } + + /** + * Parse the processor from ProcessorVersion resource. + * + * @param {string} processorVersionName + * A fully-qualified path representing ProcessorVersion resource. + * @returns {string} A string representing the processor. + */ + matchProcessorFromProcessorVersionName(processorVersionName: string) { + return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).processor; + } + + /** + * Parse the processor_version from ProcessorVersion resource. + * + * @param {string} processorVersionName + * A fully-qualified path representing ProcessorVersion resource. + * @returns {string} A string representing the processor_version. + */ + matchProcessorVersionFromProcessorVersionName(processorVersionName: string) { + return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).processor_version; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.documentProcessorServiceStub && !this._terminated) { + return this.documentProcessorServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client_config.json b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client_config.json new file mode 100644 index 00000000000..2ed5da479a8 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client_config.json @@ -0,0 +1,113 @@ +{ + "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" + }, + "ListProcessorTypes": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProcessors": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetProcessor": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TrainProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListProcessorVersions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeployProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UndeployProcessorVersion": { + "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" + }, + "SetDefaultProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ReviewDocument": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "EvaluateProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetEvaluation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListEvaluations": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_proto_list.json b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_proto_list.json new file mode 100644 index 00000000000..673527d6d32 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_proto_list.json @@ -0,0 +1,12 @@ +[ + "../../protos/google/cloud/documentai/v1beta3/barcode.proto", + "../../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/document_schema.proto", + "../../protos/google/cloud/documentai/v1beta3/evaluation.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/google-cloud-documentai/v1beta3/src/v1beta3/gapic_metadata.json b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/gapic_metadata.json new file mode 100644 index 00000000000..5252ce974c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/gapic_metadata.json @@ -0,0 +1,249 @@ +{ + "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" + ] + }, + "GetProcessor": { + "methods": [ + "getProcessor" + ] + }, + "GetProcessorVersion": { + "methods": [ + "getProcessorVersion" + ] + }, + "CreateProcessor": { + "methods": [ + "createProcessor" + ] + }, + "GetEvaluation": { + "methods": [ + "getEvaluation" + ] + }, + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + }, + "TrainProcessorVersion": { + "methods": [ + "trainProcessorVersion" + ] + }, + "DeleteProcessorVersion": { + "methods": [ + "deleteProcessorVersion" + ] + }, + "DeployProcessorVersion": { + "methods": [ + "deployProcessorVersion" + ] + }, + "UndeployProcessorVersion": { + "methods": [ + "undeployProcessorVersion" + ] + }, + "DeleteProcessor": { + "methods": [ + "deleteProcessor" + ] + }, + "EnableProcessor": { + "methods": [ + "enableProcessor" + ] + }, + "DisableProcessor": { + "methods": [ + "disableProcessor" + ] + }, + "SetDefaultProcessorVersion": { + "methods": [ + "setDefaultProcessorVersion" + ] + }, + "ReviewDocument": { + "methods": [ + "reviewDocument" + ] + }, + "EvaluateProcessorVersion": { + "methods": [ + "evaluateProcessorVersion" + ] + }, + "ListProcessorTypes": { + "methods": [ + "listProcessorTypes", + "listProcessorTypesStream", + "listProcessorTypesAsync" + ] + }, + "ListProcessors": { + "methods": [ + "listProcessors", + "listProcessorsStream", + "listProcessorsAsync" + ] + }, + "ListProcessorVersions": { + "methods": [ + "listProcessorVersions", + "listProcessorVersionsStream", + "listProcessorVersionsAsync" + ] + }, + "ListEvaluations": { + "methods": [ + "listEvaluations", + "listEvaluationsStream", + "listEvaluationsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DocumentProcessorServiceClient", + "rpcs": { + "ProcessDocument": { + "methods": [ + "processDocument" + ] + }, + "FetchProcessorTypes": { + "methods": [ + "fetchProcessorTypes" + ] + }, + "GetProcessor": { + "methods": [ + "getProcessor" + ] + }, + "GetProcessorVersion": { + "methods": [ + "getProcessorVersion" + ] + }, + "CreateProcessor": { + "methods": [ + "createProcessor" + ] + }, + "GetEvaluation": { + "methods": [ + "getEvaluation" + ] + }, + "BatchProcessDocuments": { + "methods": [ + "batchProcessDocuments" + ] + }, + "TrainProcessorVersion": { + "methods": [ + "trainProcessorVersion" + ] + }, + "DeleteProcessorVersion": { + "methods": [ + "deleteProcessorVersion" + ] + }, + "DeployProcessorVersion": { + "methods": [ + "deployProcessorVersion" + ] + }, + "UndeployProcessorVersion": { + "methods": [ + "undeployProcessorVersion" + ] + }, + "DeleteProcessor": { + "methods": [ + "deleteProcessor" + ] + }, + "EnableProcessor": { + "methods": [ + "enableProcessor" + ] + }, + "DisableProcessor": { + "methods": [ + "disableProcessor" + ] + }, + "SetDefaultProcessorVersion": { + "methods": [ + "setDefaultProcessorVersion" + ] + }, + "ReviewDocument": { + "methods": [ + "reviewDocument" + ] + }, + "EvaluateProcessorVersion": { + "methods": [ + "evaluateProcessorVersion" + ] + }, + "ListProcessorTypes": { + "methods": [ + "listProcessorTypes", + "listProcessorTypesStream", + "listProcessorTypesAsync" + ] + }, + "ListProcessors": { + "methods": [ + "listProcessors", + "listProcessorsStream", + "listProcessorsAsync" + ] + }, + "ListProcessorVersions": { + "methods": [ + "listProcessorVersions", + "listProcessorVersionsStream", + "listProcessorVersionsAsync" + ] + }, + "ListEvaluations": { + "methods": [ + "listEvaluations", + "listEvaluationsStream", + "listEvaluationsAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/index.ts new file mode 100644 index 00000000000..db3b76d115a --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..27e40317e22 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* 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/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..b1548f79d2e --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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/google-cloud-documentai/v1beta3/system-test/install.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/install.ts new file mode 100644 index 00000000000..557a57558e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/test/gapic_document_processor_service_v1beta3.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/test/gapic_document_processor_service_v1beta3.ts new file mode 100644 index 00000000000..8a55588da63 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/test/gapic_document_processor_service_v1beta3.ts @@ -0,0 +1,4281 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1beta3.DocumentProcessorServiceClient', () => { + describe('Common methods', () => { + 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 for the initialized client', done => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.documentProcessorServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.documentProcessorServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.processDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes processDocument with closed client', 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ProcessRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.processDocument(request), expectedError); + }); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.fetchProcessorTypes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.fetchProcessorTypes(request), expectedError); + const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes fetchProcessorTypes with closed client', 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.fetchProcessorTypes(request), expectedError); + }); + }); + + describe('getProcessor', () => { + it('invokes getProcessor 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.GetProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.Processor() + ); + client.innerApiCalls.getProcessor = stubSimpleCall(expectedResponse); + const [response] = await client.getProcessor(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessor 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.GetProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.Processor() + ); + client.innerApiCalls.getProcessor = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProcessor( + 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); + const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessor 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.GetProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProcessor = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProcessor(request), expectedError); + const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessor with closed client', 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.GetProcessorRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProcessor(request), expectedError); + }); + }); + + describe('getProcessorVersion', () => { + it('invokes getProcessorVersion 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.GetProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ); + client.innerApiCalls.getProcessorVersion = stubSimpleCall(expectedResponse); + const [response] = await client.getProcessorVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessorVersion 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.GetProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ); + client.innerApiCalls.getProcessorVersion = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProcessorVersion( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessorVersion|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessorVersion 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.GetProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProcessorVersion = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProcessorVersion with closed client', 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.GetProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProcessorVersion(request), expectedError); + }); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.CreateProcessorRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.CreateProcessorRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.CreateProcessorRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProcessor = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProcessor(request), expectedError); + const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProcessor with closed client', 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.CreateProcessorRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProcessor(request), expectedError); + }); + }); + + describe('getEvaluation', () => { + it('invokes getEvaluation 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.GetEvaluationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetEvaluationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.Evaluation() + ); + client.innerApiCalls.getEvaluation = stubSimpleCall(expectedResponse); + const [response] = await client.getEvaluation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEvaluation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEvaluation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEvaluation 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.GetEvaluationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetEvaluationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.Evaluation() + ); + client.innerApiCalls.getEvaluation = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEvaluation( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IEvaluation|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getEvaluation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEvaluation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEvaluation 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.GetEvaluationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetEvaluationRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEvaluation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getEvaluation(request), expectedError); + const actualRequest = (client.innerApiCalls.getEvaluation as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getEvaluation as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEvaluation with closed client', 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.GetEvaluationRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetEvaluationRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEvaluation(request), expectedError); + }); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.BatchProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.BatchProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.BatchProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.batchProcessDocuments(request), expectedError); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.BatchProcessRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.batchProcessDocuments(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('trainProcessorVersion', () => { + it('invokes trainProcessorVersion 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.TrainProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.trainProcessorVersion = stubLongRunningCall(expectedResponse); + const [operation] = await client.trainProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.trainProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.trainProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes trainProcessorVersion 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.TrainProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.trainProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.trainProcessorVersion( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.trainProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.trainProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes trainProcessorVersion 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.TrainProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.trainProcessorVersion = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.trainProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.trainProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.trainProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes trainProcessorVersion 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.TrainProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.trainProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.trainProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.trainProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.trainProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkTrainProcessorVersionProgress 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.checkTrainProcessorVersionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkTrainProcessorVersionProgress 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.checkTrainProcessorVersionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteProcessorVersion', () => { + it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProcessorVersion( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteProcessorVersionProgress 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.checkDeleteProcessorVersionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteProcessorVersionProgress 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.checkDeleteProcessorVersionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deployProcessorVersion', () => { + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(expectedResponse); + const [operation] = await client.deployProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deployProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deployProcessorVersion( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deployProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deployProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeployProcessorVersionProgress 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.checkDeployProcessorVersionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeployProcessorVersionProgress 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.checkDeployProcessorVersionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('undeployProcessorVersion', () => { + it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(expectedResponse); + const [operation] = await client.undeployProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeployProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeployProcessorVersion( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.undeployProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.undeployProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUndeployProcessorVersionProgress 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.checkUndeployProcessorVersionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUndeployProcessorVersionProgress 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.checkUndeployProcessorVersionProgress(''), 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteProcessor(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteProcessor(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.EnableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.EnableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.EnableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.enableProcessor(request), expectedError); + const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.EnableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.enableProcessor(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DisableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DisableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DisableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.disableProcessor(request), expectedError); + const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.DisableProcessorRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.disableProcessor(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('setDefaultProcessorVersion', () => { + it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionRequest', ['processor']); + request.processor = defaultValue1; + const expectedHeaderRequestParams = `processor=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(expectedResponse); + const [operation] = await client.setDefaultProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionRequest', ['processor']); + request.processor = defaultValue1; + const expectedHeaderRequestParams = `processor=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setDefaultProcessorVersion( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionRequest', ['processor']); + request.processor = defaultValue1; + const expectedHeaderRequestParams = `processor=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setDefaultProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionRequest', ['processor']); + request.processor = defaultValue1; + const expectedHeaderRequestParams = `processor=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setDefaultProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkSetDefaultProcessorVersionProgress 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.checkSetDefaultProcessorVersionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkSetDefaultProcessorVersionProgress 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.checkSetDefaultProcessorVersionProgress(''), 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ReviewDocumentRequest', ['humanReviewConfig']); + request.humanReviewConfig = defaultValue1; + const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ReviewDocumentRequest', ['humanReviewConfig']); + request.humanReviewConfig = defaultValue1; + const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ReviewDocumentRequest', ['humanReviewConfig']); + request.humanReviewConfig = defaultValue1; + const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.reviewDocument(request), expectedError); + const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ReviewDocumentRequest', ['humanReviewConfig']); + request.humanReviewConfig = defaultValue1; + const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.reviewDocument(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('evaluateProcessorVersion', () => { + it('invokes evaluateProcessorVersion 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.EvaluateProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', ['processorVersion']); + request.processorVersion = defaultValue1; + const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.evaluateProcessorVersion = stubLongRunningCall(expectedResponse); + const [operation] = await client.evaluateProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes evaluateProcessorVersion 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.EvaluateProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', ['processorVersion']); + request.processorVersion = defaultValue1; + const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.evaluateProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.evaluateProcessorVersion( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes evaluateProcessorVersion 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.EvaluateProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', ['processorVersion']); + request.processorVersion = defaultValue1; + const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.evaluateProcessorVersion = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.evaluateProcessorVersion(request), expectedError); + const actualRequest = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes evaluateProcessorVersion 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.EvaluateProcessorVersionRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', ['processorVersion']); + request.processorVersion = defaultValue1; + const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.evaluateProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.evaluateProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkEvaluateProcessorVersionProgress 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.checkEvaluateProcessorVersionProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkEvaluateProcessorVersionProgress 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.checkEvaluateProcessorVersionProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProcessorTypes', () => { + it('invokes listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + ]; + client.innerApiCalls.listProcessorTypes = stubSimpleCall(expectedResponse); + const [response] = await client.listProcessorTypes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + ]; + client.innerApiCalls.listProcessorTypes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProcessorTypes( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessorType[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProcessorTypes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProcessorTypes(request), expectedError); + const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorTypesStream 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + ]; + client.descriptors.page.listProcessorTypes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProcessorTypesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1beta3.ProcessorType[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1beta3.ProcessorType) => { + 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.listProcessorTypes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProcessorTypes, request)); + assert( + (client.descriptors.page.listProcessorTypes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProcessorTypesStream 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProcessorTypes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProcessorTypesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1beta3.ProcessorType[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1beta3.ProcessorType) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProcessorTypes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProcessorTypes, request)); + assert( + (client.descriptors.page.listProcessorTypes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), + ]; + client.descriptors.page.listProcessorTypes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.documentai.v1beta3.IProcessorType[] = []; + const iterable = client.listProcessorTypesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProcessorTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProcessorTypesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.documentai.v1beta3.IProcessorType[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProcessors = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProcessors(request), expectedError); + const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProcessors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProcessors.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProcessorVersions', () => { + it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + ]; + client.innerApiCalls.listProcessorVersions = stubSimpleCall(expectedResponse); + const [response] = await client.listProcessorVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + ]; + client.innerApiCalls.listProcessorVersions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProcessorVersions( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessorVersion[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProcessorVersions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProcessorVersions(request), expectedError); + const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorVersionsStream 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + ]; + client.descriptors.page.listProcessorVersions.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProcessorVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1beta3.ProcessorVersion[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1beta3.ProcessorVersion) => { + 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.listProcessorVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProcessorVersions, request)); + assert( + (client.descriptors.page.listProcessorVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProcessorVersionsStream 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProcessorVersions.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProcessorVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1beta3.ProcessorVersion[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1beta3.ProcessorVersion) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProcessorVersions.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProcessorVersions, request)); + assert( + (client.descriptors.page.listProcessorVersions.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), + ]; + client.descriptors.page.listProcessorVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.documentai.v1beta3.IProcessorVersion[] = []; + const iterable = client.listProcessorVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProcessorVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProcessorVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.documentai.v1beta3.IProcessorVersion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listEvaluations', () => { + it('invokes listEvaluations 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.ListEvaluationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + ]; + client.innerApiCalls.listEvaluations = stubSimpleCall(expectedResponse); + const [response] = await client.listEvaluations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listEvaluations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEvaluations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEvaluations 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.ListEvaluationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + ]; + client.innerApiCalls.listEvaluations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEvaluations( + request, + (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IEvaluation[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listEvaluations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEvaluations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEvaluations 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.ListEvaluationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEvaluations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listEvaluations(request), expectedError); + const actualRequest = (client.innerApiCalls.listEvaluations as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listEvaluations as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEvaluationsStream 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.ListEvaluationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + ]; + client.descriptors.page.listEvaluations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listEvaluationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1beta3.Evaluation[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1beta3.Evaluation) => { + 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.listEvaluations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEvaluations, request)); + assert( + (client.descriptors.page.listEvaluations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listEvaluationsStream 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.ListEvaluationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEvaluations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listEvaluationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1beta3.Evaluation[] = []; + stream.on('data', (response: protos.google.cloud.documentai.v1beta3.Evaluation) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listEvaluations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listEvaluations, request)); + assert( + (client.descriptors.page.listEvaluations.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listEvaluations 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.ListEvaluationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), + ]; + client.descriptors.page.listEvaluations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.documentai.v1beta3.IEvaluation[] = []; + const iterable = client.listEvaluationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listEvaluations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listEvaluations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listEvaluations 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.ListEvaluationsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEvaluations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEvaluationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.documentai.v1beta3.IEvaluation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listEvaluations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listEvaluations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('evaluation', () => { + const fakePath = "/rendered/path/evaluation"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + processor: "processorValue", + processor_version: "processorVersionValue", + evaluation: "evaluationValue", + }; + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.evaluationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.evaluationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('evaluationPath', () => { + const result = client.evaluationPath("projectValue", "locationValue", "processorValue", "processorVersionValue", "evaluationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.evaluationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromEvaluationName', () => { + const result = client.matchProjectFromEvaluationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.evaluationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromEvaluationName', () => { + const result = client.matchLocationFromEvaluationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.evaluationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorFromEvaluationName', () => { + const result = client.matchProcessorFromEvaluationName(fakePath); + assert.strictEqual(result, "processorValue"); + assert((client.pathTemplates.evaluationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorVersionFromEvaluationName', () => { + const result = client.matchProcessorVersionFromEvaluationName(fakePath); + assert.strictEqual(result, "processorVersionValue"); + assert((client.pathTemplates.evaluationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchEvaluationFromEvaluationName', () => { + const result = client.matchEvaluationFromEvaluationName(fakePath); + assert.strictEqual(result, "evaluationValue"); + assert((client.pathTemplates.evaluationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + 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('processorVersion', () => { + const fakePath = "/rendered/path/processorVersion"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + processor: "processorValue", + processor_version: "processorVersionValue", + }; + const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.processorVersionPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.processorVersionPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('processorVersionPath', () => { + const result = client.processorVersionPath("projectValue", "locationValue", "processorValue", "processorVersionValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.processorVersionPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProcessorVersionName', () => { + const result = client.matchProjectFromProcessorVersionName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromProcessorVersionName', () => { + const result = client.matchLocationFromProcessorVersionName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorFromProcessorVersionName', () => { + const result = client.matchProcessorFromProcessorVersionName(fakePath); + assert.strictEqual(result, "processorValue"); + assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProcessorVersionFromProcessorVersionName', () => { + const result = client.matchProcessorVersionFromProcessorVersionName(fakePath); + assert.strictEqual(result, "processorVersionValue"); + assert((client.pathTemplates.processorVersionPathTemplate.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/google-cloud-documentai/v1beta3/tsconfig.json b/owl-bot-staging/google-cloud-documentai/v1beta3/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta3/webpack.config.js b/owl-bot-staging/google-cloud-documentai/v1beta3/webpack.config.js new file mode 100644 index 00000000000..fc7bef574e6 --- /dev/null +++ b/owl-bot-staging/google-cloud-documentai/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 017b15d61119338c0d2344c652bdd05edb206da4 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 15 Nov 2022 19:54:43 +0000 Subject: [PATCH 2/4] feat: added field_mask field in DocumentOutputConfig.GcsOutputConfig in document_io.proto PiperOrigin-RevId: 488680436 Source-Link: https://github.com/googleapis/googleapis/commit/d1e4539c528ccc0fff0db0cc1d0349a5f8de8c6c Source-Link: https://github.com/googleapis/googleapis-gen/commit/6c358d9b82fb373d36a9578c3de6e13e561c9742 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRvY3VtZW50YWkvLk93bEJvdC55YW1sIiwiaCI6IjZjMzU4ZDliODJmYjM3M2QzNmE5NTc4YzNkZTZlMTNlNTYxYzk3NDIifQ== --- .../google/cloud/documentai/v1beta3/document_io.proto | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto index e10bea84087..e41458e0a24 100644 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto @@ -16,6 +16,8 @@ syntax = "proto3"; package google.cloud.documentai.v1beta3; +import "google/protobuf/field_mask.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; @@ -74,6 +76,11 @@ message DocumentOutputConfig { message GcsOutputConfig { // The Cloud Storage uri (a directory) of the output. string gcs_uri = 1; + + // Specifies which fields to include in the output documents. + // Only supports top level document and pages field so it must be in the + // form of `{document_field_name}` or `pages.{page_field_name}`. + google.protobuf.FieldMask field_mask = 2; } // The destination of the results. From 2722543e7ff92395bd6f048db11b5037488b29c4 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 6 Dec 2022 03:52:56 +0000 Subject: [PATCH 3/4] chore: Enable requesting numeric enums in "transport=rest" responses for services supporting this (Java, Go, Python, PHP, TypeScript, C#, and Ruby), even if they do not yet turn on REST transport chore: disallow "transport=rest" for services where numeric enums are not confirmed to be supported (except in PHP and Java) PiperOrigin-RevId: 493113566 Source-Link: https://github.com/googleapis/googleapis/commit/758f0d1217d9c7fe398aa5efb1057ce4b6409e55 Source-Link: https://github.com/googleapis/googleapis-gen/commit/78bd8f05e1276363eb14eae70e91fe4bc20703ab Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRvY3VtZW50YWkvLk93bEJvdC55YW1sIiwiaCI6Ijc4YmQ4ZjA1ZTEyNzYzNjNlYjE0ZWFlNzBlOTFmZTRiYzIwNzAzYWIifQ== --- .../v1/src/v1/document_processor_service_client.ts | 3 +++ .../src/v1beta1/document_understanding_service_client.ts | 3 +++ .../src/v1beta2/document_understanding_service_client.ts | 3 +++ .../v1beta3/src/v1beta3/document_processor_service_client.ts | 3 +++ 4 files changed, 12 insertions(+) diff --git a/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts index a2417e84836..8f4d9430dd2 100644 --- a/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts +++ b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts @@ -110,6 +110,9 @@ export class DocumentProcessorServiceClient { const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts index daf84de1622..e330663b00b 100644 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts +++ b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts @@ -107,6 +107,9 @@ export class DocumentUnderstandingServiceClient { const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts index 40473d60f3e..469642d50d4 100644 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts +++ b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts @@ -107,6 +107,9 @@ export class DocumentUnderstandingServiceClient { const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts index 3d65687363a..06dca98717e 100644 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts +++ b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts @@ -110,6 +110,9 @@ export class DocumentProcessorServiceClient { const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; From f1e6d802b65bdb4473038620a42188bcf404ad3c Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 6 Dec 2022 04:37:42 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../google-cloud-documentai/v1/.eslintignore | 7 - .../google-cloud-documentai/v1/.eslintrc.json | 3 - .../google-cloud-documentai/v1/.gitignore | 14 - .../google-cloud-documentai/v1/.jsdoc.js | 55 - .../google-cloud-documentai/v1/.mocharc.js | 33 - .../google-cloud-documentai/v1/.prettierrc.js | 22 - .../google-cloud-documentai/v1/README.md | 1 - .../v1/linkinator.config.json | 16 - .../google-cloud-documentai/v1/package.json | 64 - .../google/cloud/documentai/v1/barcode.proto | 69 - .../google/cloud/documentai/v1/document.proto | 820 -- .../cloud/documentai/v1/document_io.proto | 91 - .../v1/document_processor_service.proto | 801 -- .../cloud/documentai/v1/document_schema.proto | 141 - .../google/cloud/documentai/v1/geometry.proto | 55 - .../documentai/v1/operation_metadata.proto | 66 - .../cloud/documentai/v1/processor.proto | 189 - .../cloud/documentai/v1/processor_type.proto | 63 - ...ocessor_service.batch_process_documents.js | 79 - ...ment_processor_service.create_processor.js | 68 - ...ment_processor_service.delete_processor.js | 62 - ...cessor_service.delete_processor_version.js | 62 - ...cessor_service.deploy_processor_version.js | 62 - ...ent_processor_service.disable_processor.js | 62 - ...ment_processor_service.enable_processor.js | 62 - ...processor_service.fetch_processor_types.js | 63 - ...ocument_processor_service.get_processor.js | 61 - ...processor_service.get_processor_version.js | 61 - ..._processor_service.list_processor_types.js | 75 - ...ocessor_service.list_processor_versions.js | 75 - ...ument_processor_service.list_processors.js | 75 - ...ment_processor_service.process_document.js | 85 - ...ument_processor_service.review_document.js | 79 - ...r_service.set_default_processor_version.js | 69 - ...ssor_service.undeploy_processor_version.js | 62 - ...t_metadata.google.cloud.documentai.v1.json | 771 -- .../google-cloud-documentai/v1/src/index.ts | 25 - .../v1/document_processor_service_client.ts | 2763 ------ ...ument_processor_service_client_config.json | 97 - ...document_processor_service_proto_list.json | 11 - .../v1/src/v1/gapic_metadata.json | 205 - .../v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../v1/system-test/install.ts | 49 - .../gapic_document_processor_service_v1.ts | 3558 ------- .../google-cloud-documentai/v1/tsconfig.json | 19 - .../v1/webpack.config.js | 64 - .../v1beta1/.eslintignore | 7 - .../v1beta1/.eslintrc.json | 3 - .../v1beta1/.gitignore | 14 - .../google-cloud-documentai/v1beta1/.jsdoc.js | 55 - .../v1beta1/.mocharc.js | 33 - .../v1beta1/.prettierrc.js | 22 - .../google-cloud-documentai/v1beta1/README.md | 1 - .../v1beta1/linkinator.config.json | 16 - .../v1beta1/package.json | 64 - .../cloud/documentai/v1beta1/document.proto | 449 - .../v1beta1/document_understanding.proto | 302 - .../cloud/documentai/v1beta1/geometry.proto | 57 - ...tanding_service.batch_process_documents.js | 68 - ...adata.google.cloud.documentai.v1beta1.json | 59 - .../v1beta1/src/index.ts | 25 - .../document_understanding_service_client.ts | 434 - ...t_understanding_service_client_config.json | 31 - ...ment_understanding_service_proto_list.json | 5 - .../v1beta1/src/v1beta1/gapic_metadata.json | 33 - .../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 | 316 - .../v1beta1/tsconfig.json | 19 - .../v1beta1/webpack.config.js | 64 - .../v1beta2/.eslintignore | 7 - .../v1beta2/.eslintrc.json | 3 - .../v1beta2/.gitignore | 14 - .../google-cloud-documentai/v1beta2/.jsdoc.js | 55 - .../v1beta2/.mocharc.js | 33 - .../v1beta2/.prettierrc.js | 22 - .../google-cloud-documentai/v1beta2/README.md | 1 - .../v1beta2/linkinator.config.json | 16 - .../v1beta2/package.json | 64 - .../cloud/documentai/v1beta2/document.proto | 518 - .../v1beta2/document_understanding.proto | 346 - .../cloud/documentai/v1beta2/geometry.proto | 56 - ...tanding_service.batch_process_documents.js | 68 - ..._understanding_service.process_document.js | 104 - ...adata.google.cloud.documentai.v1beta2.json | 131 - .../v1beta2/src/index.ts | 25 - .../document_understanding_service_client.ts | 535 - ...t_understanding_service_client_config.json | 36 - ...ment_understanding_service_proto_list.json | 5 - .../v1beta2/src/v1beta2/gapic_metadata.json | 43 - .../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 | 428 - .../v1beta2/tsconfig.json | 19 - .../v1beta2/webpack.config.js | 64 - .../v1beta3/.eslintignore | 7 - .../v1beta3/.eslintrc.json | 3 - .../v1beta3/.gitignore | 14 - .../google-cloud-documentai/v1beta3/.jsdoc.js | 55 - .../v1beta3/.mocharc.js | 33 - .../v1beta3/.prettierrc.js | 22 - .../google-cloud-documentai/v1beta3/README.md | 1 - .../v1beta3/linkinator.config.json | 16 - .../v1beta3/package.json | 64 - .../cloud/documentai/v1beta3/barcode.proto | 69 - .../cloud/documentai/v1beta3/document.proto | 820 -- .../documentai/v1beta3/document_io.proto | 91 - .../v1beta3/document_processor_service.proto | 1070 -- .../documentai/v1beta3/document_schema.proto | 141 - .../cloud/documentai/v1beta3/geometry.proto | 55 - .../v1beta3/operation_metadata.proto | 66 - .../cloud/documentai/v1beta3/processor.proto | 189 - .../documentai/v1beta3/processor_type.proto | 63 - ...ocessor_service.batch_process_documents.js | 87 - ...ment_processor_service.create_processor.js | 68 - ...ment_processor_service.delete_processor.js | 62 - ...cessor_service.delete_processor_version.js | 62 - ...cessor_service.deploy_processor_version.js | 62 - ...ent_processor_service.disable_processor.js | 62 - ...ment_processor_service.enable_processor.js | 62 - ...processor_service.fetch_processor_types.js | 63 - ...ocument_processor_service.get_processor.js | 61 - ...processor_service.get_processor_version.js | 61 - ..._processor_service.list_processor_types.js | 75 - ...ocessor_service.list_processor_versions.js | 75 - ...ument_processor_service.list_processors.js | 75 - ...ment_processor_service.process_document.js | 89 - ...ument_processor_service.review_document.js | 83 - ...r_service.set_default_processor_version.js | 69 - ...ssor_service.undeploy_processor_version.js | 62 - ...adata.google.cloud.documentai.v1beta3.json | 975 -- .../v1beta3/src/index.ts | 25 - .../document_processor_service_client.ts | 3324 ------- ...ument_processor_service_client_config.json | 113 - ...document_processor_service_proto_list.json | 12 - .../v1beta3/src/v1beta3/gapic_metadata.json | 249 - .../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 | 4281 -------- .../v1beta3/tsconfig.json | 19 - .../v1beta3/webpack.config.js | 64 - packages/google-cloud-documentai/README.md | 4 + .../cloud/documentai/v1beta3/barcode.proto | 56 +- .../cloud/documentai/v1beta3/document.proto | 72 +- .../documentai/v1beta3/document_io.proto | 11 +- .../v1beta3/document_processor_service.proto | 192 + .../documentai/v1beta3/document_schema.proto | 7 +- .../cloud/documentai/v1beta3/evaluation.proto | 0 .../cloud/documentai/v1beta3/processor.proto | 14 +- .../documentai/v1beta3/processor_type.proto | 4 +- .../protos/protos.d.ts | 3195 +++++- .../google-cloud-documentai/protos/protos.js | 8837 +++++++++++++---- .../protos/protos.json | 512 +- .../google-cloud-documentai/samples/README.md | 72 + ...ssor_service.evaluate_processor_version.js | 0 ...cument_processor_service.get_evaluation.js | 0 ...ment_processor_service.list_evaluations.js | 0 ...ment_processor_service.process_document.js | 2 + ...ocessor_service.train_processor_version.js | 0 ...adata.google.cloud.documentai.v1beta3.json | 190 +- .../v1/document_processor_service_client.ts | 11 +- .../document_understanding_service_client.ts | 12 +- .../document_understanding_service_client.ts | 12 +- .../document_processor_service_client.ts | 730 +- ...ument_processor_service_client_config.json | 16 + ...document_processor_service_proto_list.json | 1 + .../src/v1beta3/gapic_metadata.json | 44 + ...apic_document_processor_service_v1beta3.ts | 1532 ++- release-please-config.json | 1 - 177 files changed, 12836 insertions(+), 32073 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/README.md delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/package.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/barcode.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_io.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_processor_service.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_schema.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/geometry.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/operation_metadata.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor_type.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.batch_process_documents.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.create_processor.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor_version.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.deploy_processor_version.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.disable_processor.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.enable_processor.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.fetch_processor_types.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor_version.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_types.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_versions.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processors.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.process_document.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.review_document.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.set_default_processor_version.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.undeploy_processor_version.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/snippet_metadata.google.cloud.documentai.v1.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/test/gapic_document_processor_service_v1.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.gitignore delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/README.md delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/package.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/document_understanding_service.batch_process_documents.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.documentai.v1beta1.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/test/gapic_document_understanding_service_v1beta1.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta1/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.gitignore delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/README.md delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/package.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.batch_process_documents.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.process_document.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.documentai.v1beta2.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/test/gapic_document_understanding_service_v1beta2.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta2/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.gitignore delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/README.md delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/package.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/barcode.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_schema.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.batch_process_documents.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.create_processor.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor_version.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.deploy_processor_version.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.disable_processor.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.enable_processor.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor_version.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_types.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_versions.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processors.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.process_document.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.review_document.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.set_default_processor_version.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/test/gapic_document_processor_service_v1beta3.ts delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-documentai/v1beta3/webpack.config.js rename {owl-bot-staging/google-cloud-documentai/v1beta3 => packages/google-cloud-documentai}/protos/google/cloud/documentai/v1beta3/evaluation.proto (100%) rename {owl-bot-staging/google-cloud-documentai/v1beta3 => packages/google-cloud-documentai}/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js (100%) rename {owl-bot-staging/google-cloud-documentai/v1beta3 => packages/google-cloud-documentai}/samples/generated/v1beta3/document_processor_service.get_evaluation.js (100%) rename {owl-bot-staging/google-cloud-documentai/v1beta3 => packages/google-cloud-documentai}/samples/generated/v1beta3/document_processor_service.list_evaluations.js (100%) rename {owl-bot-staging/google-cloud-documentai/v1beta3 => packages/google-cloud-documentai}/samples/generated/v1beta3/document_processor_service.train_processor_version.js (100%) diff --git a/owl-bot-staging/google-cloud-documentai/v1/.eslintignore b/owl-bot-staging/google-cloud-documentai/v1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-documentai/v1/.eslintrc.json b/owl-bot-staging/google-cloud-documentai/v1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/.gitignore b/owl-bot-staging/google-cloud-documentai/v1/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/google-cloud-documentai/v1/.jsdoc.js b/owl-bot-staging/google-cloud-documentai/v1/.jsdoc.js deleted file mode 100644 index 75c76e52a54..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/documentai', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-documentai/v1/.mocharc.js b/owl-bot-staging/google-cloud-documentai/v1/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-documentai/v1/.prettierrc.js b/owl-bot-staging/google-cloud-documentai/v1/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/README.md b/owl-bot-staging/google-cloud-documentai/v1/README.md deleted file mode 100644 index f41eef852ae..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Documentai: Nodejs Client diff --git a/owl-bot-staging/google-cloud-documentai/v1/linkinator.config.json b/owl-bot-staging/google-cloud-documentai/v1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/package.json b/owl-bot-staging/google-cloud-documentai/v1/package.json deleted file mode 100644 index 41e8970a7ad..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/barcode.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/barcode.proto deleted file mode 100644 index bb841771ade..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/barcode.proto +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "BarcodeProto"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// Encodes the detailed information of a barcode. -message Barcode { - // Format of a barcode. - // The supported formats are: - // - // - `CODE_128`: Code 128 type. - // - `CODE_39`: Code 39 type. - // - `CODE_93`: Code 93 type. - // - `CODABAR`: Codabar type. - // - `DATA_MATRIX`: 2D Data Matrix type. - // - `ITF`: ITF type. - // - `EAN_13`: EAN-13 type. - // - `EAN_8`: EAN-8 type. - // - `QR_CODE`: 2D QR code type. - // - `UPC_A`: UPC-A type. - // - `UPC_E`: UPC-E type. - // - `PDF417`: PDF417 type. - // - `AZTEC`: 2D Aztec code type. - // - `DATABAR`: GS1 DataBar code type. - string format = 1; - - // Value format describes the format of the value that a barcode - // encodes. - // The supported formats are: - // - // - `CONTACT_INFO`: Contact information. - // - `EMAIL`: Email address. - // - `ISBN`: ISBN identifier. - // - `PHONE`: Phone number. - // - `PRODUCT`: Product. - // - `SMS`: SMS message. - // - `TEXT`: Text string. - // - `URL`: URL address. - // - `WIFI`: Wifi information. - // - `GEO`: Geo-localization. - // - `CALENDAR_EVENT`: Calendar event. - // - `DRIVER_LICENSE`: Driver's license. - string value_format = 2; - - // Raw value encoded in the barcode. - // For example: `'MEBKM:TITLE:Google;URL:https://www.google.com;;'`. - string raw_value = 3; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document.proto deleted file mode 100644 index c4fbb21ceca..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document.proto +++ /dev/null @@ -1,820 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/api/field_behavior.proto"; -import "google/cloud/documentai/v1/barcode.proto"; -import "google/cloud/documentai/v1/geometry.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; -import "google/type/color.proto"; -import "google/type/date.proto"; -import "google/type/datetime.proto"; -import "google/type/money.proto"; -import "google/type/postal_address.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentProto"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// Document represents the canonical document resource in Document AI. It is an -// interchange format that provides insights into documents and allows for -// collaboration between users and Document AI to iterate and optimize for -// quality. -message Document { - // For a large document, sharding may be performed to produce several - // document shards. Each document shard contains this field to detail which - // shard it is. - message ShardInfo { - // The 0-based index of this shard. - int64 shard_index = 1; - - // Total number of shards. - int64 shard_count = 2; - - // The index of the first character in [Document.text][google.cloud.documentai.v1.Document.text] in the overall - // document global text. - int64 text_offset = 3; - } - - // Annotation for common text style attributes. This adheres to CSS - // conventions as much as possible. - message Style { - // Font size with unit. - message FontSize { - // Font size for the text. - float size = 1; - - // Unit for the font size. Follows CSS naming (in, px, pt, etc.). - string unit = 2; - } - - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. - TextAnchor text_anchor = 1; - - // Text color. - google.type.Color color = 2; - - // Text background color. - google.type.Color background_color = 3; - - // Font weight. Possible values are normal, bold, bolder, and lighter. - // https://www.w3schools.com/cssref/pr_font_weight.asp - string font_weight = 4; - - // Text style. Possible values are normal, italic, and oblique. - // https://www.w3schools.com/cssref/pr_font_font-style.asp - string text_style = 5; - - // Text decoration. Follows CSS standard. - // - // https://www.w3schools.com/cssref/pr_text_text-decoration.asp - string text_decoration = 6; - - // Font size. - FontSize font_size = 7; - - // Font family such as `Arial`, `Times New Roman`. - // https://www.w3schools.com/cssref/pr_font_font-family.asp - string font_family = 8; - } - - // A page in a [Document][google.cloud.documentai.v1.Document]. - message Page { - // Dimension for the page. - message Dimension { - // Page width. - float width = 1; - - // Page height. - float height = 2; - - // Dimension unit. - string unit = 3; - } - - // Rendered image contents for this page. - message Image { - // Raw byte content of the image. - bytes content = 1; - - // Encoding mime type for the image. - string mime_type = 2; - - // Width of the image in pixels. - int32 width = 3; - - // Height of the image in pixels. - int32 height = 4; - } - - // Representation for transformation matrix, intended to be compatible and - // used with OpenCV format for image manipulation. - message Matrix { - // Number of rows in the matrix. - int32 rows = 1; - - // Number of columns in the matrix. - int32 cols = 2; - - // This encodes information about what data type the matrix uses. - // For example, 0 (CV_8U) is an unsigned 8-bit image. For the full list - // of OpenCV primitive data types, please refer to - // https://docs.opencv.org/4.3.0/d1/d1b/group__core__hal__interface.html - int32 type = 3; - - // The matrix data. - bytes data = 4; - } - - // Visual element describing a layout unit on a page. - message Layout { - // Detected human reading orientation. - enum Orientation { - // Unspecified orientation. - ORIENTATION_UNSPECIFIED = 0; - - // Orientation is aligned with page up. - PAGE_UP = 1; - - // Orientation is aligned with page right. - // Turn the head 90 degrees clockwise from upright to read. - PAGE_RIGHT = 2; - - // Orientation is aligned with page down. - // Turn the head 180 degrees from upright to read. - PAGE_DOWN = 3; - - // Orientation is aligned with page left. - // Turn the head 90 degrees counterclockwise from upright to read. - PAGE_LEFT = 4; - } - - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. - TextAnchor text_anchor = 1; - - // Confidence of the current [Layout][google.cloud.documentai.v1.Document.Page.Layout] within context of the object this - // layout is for. e.g. confidence can be for a single token, a table, - // a visual element, etc. depending on context. Range `[0, 1]`. - float confidence = 2; - - // The bounding polygon for the [Layout][google.cloud.documentai.v1.Document.Page.Layout]. - BoundingPoly bounding_poly = 3; - - // Detected orientation for the [Layout][google.cloud.documentai.v1.Document.Page.Layout]. - Orientation orientation = 4; - } - - // A block has a set of lines (collected into paragraphs) that have a - // common line-spacing and orientation. - message Block { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Block][google.cloud.documentai.v1.Document.Page.Block]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - - // The history of this annotation. - Provenance provenance = 3 [deprecated = true]; - } - - // A collection of lines that a human would perceive as a paragraph. - message Paragraph { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Paragraph][google.cloud.documentai.v1.Document.Page.Paragraph]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - - // The history of this annotation. - Provenance provenance = 3 [deprecated = true]; - } - - // A collection of tokens that a human would perceive as a line. - // Does not cross column boundaries, can be horizontal, vertical, etc. - message Line { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Line][google.cloud.documentai.v1.Document.Page.Line]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - - // The history of this annotation. - Provenance provenance = 3 [deprecated = true]; - } - - // A detected token. - message Token { - // Detected break at the end of a [Token][google.cloud.documentai.v1.Document.Page.Token]. - message DetectedBreak { - // Enum to denote the type of break found. - enum Type { - // Unspecified break type. - TYPE_UNSPECIFIED = 0; - - // A single whitespace. - SPACE = 1; - - // A wider whitespace. - WIDE_SPACE = 2; - - // A hyphen that indicates that a token has been split across lines. - HYPHEN = 3; - } - - // Detected break type. - Type type = 1; - } - - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Token][google.cloud.documentai.v1.Document.Page.Token]. - Layout layout = 1; - - // Detected break at the end of a [Token][google.cloud.documentai.v1.Document.Page.Token]. - DetectedBreak detected_break = 2; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 3; - - // The history of this annotation. - Provenance provenance = 4 [deprecated = true]; - } - - // A detected symbol. - message Symbol { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Symbol][google.cloud.documentai.v1.Document.Page.Symbol]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - } - - // Detected non-text visual elements e.g. checkbox, signature etc. on the - // page. - message VisualElement { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [VisualElement][google.cloud.documentai.v1.Document.Page.VisualElement]. - Layout layout = 1; - - // Type of the [VisualElement][google.cloud.documentai.v1.Document.Page.VisualElement]. - string type = 2; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 3; - } - - // A table representation similar to HTML table structure. - message Table { - // A row of table cells. - message TableRow { - // Cells that make up this row. - repeated TableCell cells = 1; - } - - // A cell representation inside the table. - message TableCell { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [TableCell][google.cloud.documentai.v1.Document.Page.Table.TableCell]. - Layout layout = 1; - - // How many rows this cell spans. - int32 row_span = 2; - - // How many columns this cell spans. - int32 col_span = 3; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 4; - } - - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [Table][google.cloud.documentai.v1.Document.Page.Table]. - Layout layout = 1; - - // Header rows of the table. - repeated TableRow header_rows = 2; - - // Body rows of the table. - repeated TableRow body_rows = 3; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 4; - - // The history of this table. - Provenance provenance = 5; - } - - // A form field detected on the page. - message FormField { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1.Document.Page.FormField] name. e.g. `Address`, `Email`, - // `Grand total`, `Phone number`, etc. - Layout field_name = 1; - - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the [FormField][google.cloud.documentai.v1.Document.Page.FormField] value. - Layout field_value = 2; - - // A list of detected languages for name together with confidence. - repeated DetectedLanguage name_detected_languages = 3; - - // A list of detected languages for value together with confidence. - repeated DetectedLanguage value_detected_languages = 4; - - // If the value is non-textual, this field represents the type. Current - // valid values are: - // - blank (this indicates the field_value is normal text) - // - "unfilled_checkbox" - // - "filled_checkbox" - string value_type = 5; - - // Created for Labeling UI to export key text. - // If corrections were made to the text identified by the - // `field_name.text_anchor`, this field will contain the correction. - string corrected_key_text = 6; - - // Created for Labeling UI to export value text. - // If corrections were made to the text identified by the - // `field_value.text_anchor`, this field will contain the correction. - string corrected_value_text = 7; - - // The history of this annotation. - Provenance provenance = 8; - } - - // A detected barcode. - message DetectedBarcode { - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for [DetectedBarcode][google.cloud.documentai.v1.Document.Page.DetectedBarcode]. - Layout layout = 1; - - // Detailed barcode information of the [DetectedBarcode][google.cloud.documentai.v1.Document.Page.DetectedBarcode]. - Barcode barcode = 2; - } - - // Detected language for a structural component. - message DetectedLanguage { - // The BCP-47 language code, such as `en-US` or `sr-Latn`. For more - // information, see - // https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 1; - - // Confidence of detected language. Range `[0, 1]`. - float confidence = 2; - } - - // Image Quality Scores for the page image - message ImageQualityScores { - // Image Quality Defects - message DetectedDefect { - // Name of the defect type. Supported values are: - // - // - `quality/defect_blurry` - // - `quality/defect_noisy` - // - `quality/defect_dark` - // - `quality/defect_faint` - // - `quality/defect_text_too_small` - // - `quality/defect_document_cutoff` - // - `quality/defect_text_cutoff` - // - `quality/defect_glare` - string type = 1; - - // Confidence of detected defect. Range `[0, 1]` where 1 indicates - // strong confidence of that the defect exists. - float confidence = 2; - } - - // The overall quality score. Range `[0, 1]` where 1 is perfect quality. - float quality_score = 1; - - // A list of detected defects. - repeated DetectedDefect detected_defects = 2; - } - - // 1-based index for current [Page][google.cloud.documentai.v1.Document.Page] in a parent [Document][google.cloud.documentai.v1.Document]. - // Useful when a page is taken out of a [Document][google.cloud.documentai.v1.Document] for individual - // processing. - int32 page_number = 1; - - // Rendered image for this page. This image is preprocessed to remove any - // skew, rotation, and distortions such that the annotation bounding boxes - // can be upright and axis-aligned. - Image image = 13; - - // Transformation matrices that were applied to the original document image - // to produce [Page.image][google.cloud.documentai.v1.Document.Page.image]. - repeated Matrix transforms = 14; - - // Physical dimension of the page. - Dimension dimension = 2; - - // [Layout][google.cloud.documentai.v1.Document.Page.Layout] for the page. - Layout layout = 3; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 4; - - // A list of visually detected text blocks on the page. - // A block has a set of lines (collected into paragraphs) that have a common - // line-spacing and orientation. - repeated Block blocks = 5; - - // A list of visually detected text paragraphs on the page. - // A collection of lines that a human would perceive as a paragraph. - repeated Paragraph paragraphs = 6; - - // A list of visually detected text lines on the page. - // A collection of tokens that a human would perceive as a line. - repeated Line lines = 7; - - // A list of visually detected tokens on the page. - repeated Token tokens = 8; - - // A list of detected non-text visual elements e.g. checkbox, - // signature etc. on the page. - repeated VisualElement visual_elements = 9; - - // A list of visually detected tables on the page. - repeated Table tables = 10; - - // A list of visually detected form fields on the page. - repeated FormField form_fields = 11; - - // A list of visually detected symbols on the page. - repeated Symbol symbols = 12; - - // A list of detected barcodes. - repeated DetectedBarcode detected_barcodes = 15; - - // Image Quality Scores. - ImageQualityScores image_quality_scores = 17; - - // The history of this page. - Provenance provenance = 16 [deprecated = true]; - } - - // An entity that could be a phrase in the text or a property that belongs to - // the document. It is a known entity type, such as a person, an organization, - // or location. - message Entity { - // Parsed and normalized entity value. - message NormalizedValue { - // An optional structured entity value. - // Must match entity type defined in schema if - // known. If this field is present, the `text` field could also be - // populated. - oneof structured_value { - // Money value. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/money.proto - google.type.Money money_value = 2; - - // Date value. Includes year, month, day. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/date.proto - google.type.Date date_value = 3; - - // DateTime value. Includes date, time, and timezone. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto - google.type.DateTime datetime_value = 4; - - // Postal address. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto - google.type.PostalAddress address_value = 5; - - // Boolean value. Can be used for entities with binary values, or for - // checkboxes. - bool boolean_value = 6; - - // Integer value. - int32 integer_value = 7; - - // Float value. - float float_value = 8; - } - - // Optional. An optional field to store a normalized string. - // For some entity types, one of respective `structured_value` fields may - // also be populated. Also not all the types of `structured_value` will be - // normalized. For example, some processors may not generate float - // or int normalized text by default. - // - // Below are sample formats mapped to structured values. - // - // - Money/Currency type (`money_value`) is in the ISO 4217 text format. - // - Date type (`date_value`) is in the ISO 8601 text format. - // - Datetime type (`datetime_value`) is in the ISO 8601 text format. - string text = 1 [(google.api.field_behavior) = OPTIONAL]; - } - - // Optional. Provenance of the entity. - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. - TextAnchor text_anchor = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Required. Entity type from a schema e.g. `Address`. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`. - string mention_text = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Deprecated. Use `id` field instead. - string mention_id = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Confidence of detected Schema entity. Range `[0, 1]`. - float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Represents the provenance of this entity wrt. the location on the - // page where it was found. - PageAnchor page_anchor = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Canonical id. This will be a unique value in the entity list - // for this document. - string id = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Normalized entity value. Absent if the extracted value could not be - // converted or the type (e.g. address) is not supported for certain - // parsers. This field is also only populated for certain supported document - // types. - NormalizedValue normalized_value = 9 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Entities can be nested to form a hierarchical data structure representing - // the content in the document. - repeated Entity properties = 10 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The history of this annotation. - Provenance provenance = 11 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Whether the entity will be redacted for de-identification purposes. - bool redacted = 12 [(google.api.field_behavior) = OPTIONAL]; - } - - // Relationship between [Entities][google.cloud.documentai.v1.Document.Entity]. - message EntityRelation { - // Subject entity id. - string subject_id = 1; - - // Object entity id. - string object_id = 2; - - // Relationship description. - string relation = 3; - } - - // Text reference indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. - message TextAnchor { - // A text segment in the [Document.text][google.cloud.documentai.v1.Document.text]. The indices may be out of bounds - // which indicate that the text extends into another document shard for - // large sharded documents. See [ShardInfo.text_offset][google.cloud.documentai.v1.Document.ShardInfo.text_offset] - message TextSegment { - // [TextSegment][google.cloud.documentai.v1.Document.TextAnchor.TextSegment] start UTF-8 char index in the [Document.text][google.cloud.documentai.v1.Document.text]. - int64 start_index = 1; - - // [TextSegment][google.cloud.documentai.v1.Document.TextAnchor.TextSegment] half open end UTF-8 char index in the - // [Document.text][google.cloud.documentai.v1.Document.text]. - int64 end_index = 2; - } - - // The text segments from the [Document.text][google.cloud.documentai.v1.Document.text]. - repeated TextSegment text_segments = 1; - - // Contains the content of the text span so that users do - // not have to look it up in the text_segments. It is always - // populated for formFields. - string content = 2; - } - - // Referencing the visual context of the entity in the [Document.pages][google.cloud.documentai.v1.Document.pages]. - // Page anchors can be cross-page, consist of multiple bounding polygons and - // optionally reference specific layout element types. - message PageAnchor { - // Represents a weak reference to a page element within a document. - message PageRef { - // The type of layout that is being referenced. - enum LayoutType { - // Layout Unspecified. - LAYOUT_TYPE_UNSPECIFIED = 0; - - // References a [Page.blocks][google.cloud.documentai.v1.Document.Page.blocks] element. - BLOCK = 1; - - // References a [Page.paragraphs][google.cloud.documentai.v1.Document.Page.paragraphs] element. - PARAGRAPH = 2; - - // References a [Page.lines][google.cloud.documentai.v1.Document.Page.lines] element. - LINE = 3; - - // References a [Page.tokens][google.cloud.documentai.v1.Document.Page.tokens] element. - TOKEN = 4; - - // References a [Page.visual_elements][google.cloud.documentai.v1.Document.Page.visual_elements] element. - VISUAL_ELEMENT = 5; - - // Refrrences a [Page.tables][google.cloud.documentai.v1.Document.Page.tables] element. - TABLE = 6; - - // References a [Page.form_fields][google.cloud.documentai.v1.Document.Page.form_fields] element. - FORM_FIELD = 7; - } - - // Required. Index into the [Document.pages][google.cloud.documentai.v1.Document.pages] element, for example using - // [Document.pages][page_refs.page] to locate the related page element. - // This field is skipped when its value is the default 0. See - // https://developers.google.com/protocol-buffers/docs/proto3#json. - int64 page = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The type of the layout element that is being referenced if any. - LayoutType layout_type = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Deprecated. Use [PageRef.bounding_poly][google.cloud.documentai.v1.Document.PageAnchor.PageRef.bounding_poly] instead. - string layout_id = 3 [ - deprecated = true, - (google.api.field_behavior) = OPTIONAL - ]; - - // Optional. Identifies the bounding polygon of a layout element on the page. - BoundingPoly bounding_poly = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Confidence of detected page element, if applicable. Range `[0, 1]`. - float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; - } - - // One or more references to visual page elements - repeated PageRef page_refs = 1; - } - - // Structure to identify provenance relationships between annotations in - // different revisions. - message Provenance { - // The parent element the current element is based on. Used for - // referencing/aligning, removal and replacement operations. - message Parent { - // The index of the index into current revision's parent_ids list. - int32 revision = 1; - - // The index of the parent item in the corresponding item list (eg. list - // of entities, properties within entities, etc.) in the parent revision. - int32 index = 3; - - // The id of the parent provenance. - int32 id = 2 [deprecated = true]; - } - - // If a processor or agent does an explicit operation on existing elements. - enum OperationType { - // Operation type unspecified. If no operation is specified a provenance - // entry is simply used to match against a `parent`. - OPERATION_TYPE_UNSPECIFIED = 0; - - // Add an element. - ADD = 1; - - // Remove an element identified by `parent`. - REMOVE = 2; - - // Replace an element identified by `parent`. - REPLACE = 3; - - // Request human review for the element identified by `parent`. - EVAL_REQUESTED = 4; - - // Element is reviewed and approved at human review, confidence will be - // set to 1.0. - EVAL_APPROVED = 5; - - // Element is skipped in the validation process. - EVAL_SKIPPED = 6; - } - - // The index of the revision that produced this element. - int32 revision = 1; - - // The Id of this operation. Needs to be unique within the scope of the - // revision. - int32 id = 2 [deprecated = true]; - - // References to the original elements that are replaced. - repeated Parent parents = 3; - - // The type of provenance operation. - OperationType type = 4; - } - - // Contains past or forward revisions of this document. - message Revision { - // Human Review information of the document. - message HumanReview { - // Human review state. e.g. `requested`, `succeeded`, `rejected`. - string state = 1; - - // A message providing more details about the current state of processing. - // For example, the rejection reason when the state is `rejected`. - string state_message = 2; - } - - // Who/what made the change - oneof source { - // If the change was made by a person specify the name or id of that - // person. - string agent = 4; - - // If the annotation was made by processor identify the processor by its - // resource name. - string processor = 5; - } - - // Id of the revision. Unique within the context of the document. - string id = 1; - - // The revisions that this revision is based on. This can include one or - // more parent (when documents are merged.) This field represents the - // index into the `revisions` field. - repeated int32 parent = 2 [deprecated = true]; - - // The revisions that this revision is based on. Must include all the ids - // that have anything to do with this revision - eg. there are - // `provenance.parent.revision` fields that index into this field. - repeated string parent_ids = 7; - - // The time that the revision was created. - google.protobuf.Timestamp create_time = 3; - - // Human Review information of this revision. - HumanReview human_review = 6; - } - - // This message is used for text changes aka. OCR corrections. - message TextChange { - // Provenance of the correction. - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1.Document.text]. There can only be a - // single `TextAnchor.text_segments` element. If the start and - // end index of the text segment are the same, the text change is inserted - // before that index. - TextAnchor text_anchor = 1; - - // The text that replaces the text identified in the `text_anchor`. - string changed_text = 2; - - // The history of this annotation. - repeated Provenance provenance = 3 [deprecated = true]; - } - - // Original source document from the user. - oneof source { - // Optional. Currently supports Google Cloud Storage URI of the form - // `gs://bucket_name/object_name`. Object versioning is not supported. - // See [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris) for more - // info. - string uri = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Inline document content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - bytes content = 2 [(google.api.field_behavior) = OPTIONAL]; - } - - // An IANA published MIME type (also referred to as media type). For more - // information, see - // https://www.iana.org/assignments/media-types/media-types.xhtml. - string mime_type = 3; - - // Optional. UTF-8 encoded text in reading order from the document. - string text = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Placeholder. Styles for the [Document.text][google.cloud.documentai.v1.Document.text]. - repeated Style text_styles = 5; - - // Visual page layout for the [Document][google.cloud.documentai.v1.Document]. - repeated Page pages = 6; - - // A list of entities detected on [Document.text][google.cloud.documentai.v1.Document.text]. For document shards, - // entities in this list may cross shard boundaries. - repeated Entity entities = 7; - - // Placeholder. Relationship among [Document.entities][google.cloud.documentai.v1.Document.entities]. - repeated EntityRelation entity_relations = 8; - - // Placeholder. A list of text corrections made to [Document.text][google.cloud.documentai.v1.Document.text]. This - // is usually used for annotating corrections to OCR mistakes. Text changes - // for a given revision may not overlap with each other. - repeated TextChange text_changes = 14; - - // Information about the sharding if this document is sharded part of a larger - // document. If the document is not sharded, this message is not specified. - ShardInfo shard_info = 9; - - // Any error that occurred while processing this document. - google.rpc.Status error = 10; - - // Placeholder. Revision history of this document. - repeated Revision revisions = 13; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_io.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_io.proto deleted file mode 100644 index 3240d494e8f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_io.proto +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentIoProto"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// Payload message of raw document content (bytes). -message RawDocument { - // Inline document content. - bytes content = 1; - - // An IANA MIME type (RFC6838) indicating the nature and format of the - // [content][google.cloud.documentai.v1.RawDocument.content]. - string mime_type = 2; -} - -// Specifies a document stored on Cloud Storage. -message GcsDocument { - // The Cloud Storage object uri. - string gcs_uri = 1; - - // An IANA MIME type (RFC6838) of the content. - string mime_type = 2; -} - -// Specifies a set of documents on Cloud Storage. -message GcsDocuments { - // The list of documents. - repeated GcsDocument documents = 1; -} - -// Specifies all documents on Cloud Storage with a common prefix. -message GcsPrefix { - // The URI prefix. - string gcs_uri_prefix = 1; -} - -// The common config to specify a set of documents used as input. -message BatchDocumentsInputConfig { - // The source. - oneof source { - // The set of documents that match the specified Cloud Storage `gcs_prefix`. - GcsPrefix gcs_prefix = 1; - - // The set of documents individually specified on Cloud Storage. - GcsDocuments gcs_documents = 2; - } -} - -// Config that controls the output of documents. All documents will be written -// as a JSON file. -message DocumentOutputConfig { - // The configuration used when outputting documents. - message GcsOutputConfig { - // The Cloud Storage uri (a directory) of the output. - string gcs_uri = 1; - - // Specifies which fields to include in the output documents. - // Only supports top level document and pages field so it must be in the - // form of `{document_field_name}` or `pages.{page_field_name}`. - google.protobuf.FieldMask field_mask = 2; - } - - // The destination of the results. - oneof destination { - // Output config to write the results to Cloud Storage. - GcsOutputConfig gcs_output_config = 1; - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_processor_service.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_processor_service.proto deleted file mode 100644 index e748ae1f748..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_processor_service.proto +++ /dev/null @@ -1,801 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/documentai/v1/document.proto"; -import "google/cloud/documentai/v1/document_io.proto"; -import "google/cloud/documentai/v1/document_schema.proto"; -import "google/cloud/documentai/v1/operation_metadata.proto"; -import "google/cloud/documentai/v1/processor.proto"; -import "google/cloud/documentai/v1/processor_type.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProcessorService"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; -option (google.api.resource_definition) = { - type: "documentai.googleapis.com/HumanReviewConfig" - pattern: "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" -}; -option (google.api.resource_definition) = { - type: "documentai.googleapis.com/Location" - pattern: "projects/{project}/locations/{location}" -}; - -// Service to call Cloud DocumentAI to process documents according to the -// processor's definition. Processors are built using state-of-the-art Google -// AI such as natural language, computer vision, and translation to extract -// structured information from unstructured or semi-structured documents. -service DocumentProcessorService { - option (google.api.default_host) = "documentai.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Processes a single document. - rpc ProcessDocument(ProcessRequest) returns (ProcessResponse) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*}:process" - body: "*" - additional_bindings { - post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:process" - body: "*" - } - }; - option (google.api.method_signature) = "name"; - } - - // LRO endpoint to batch process many documents. The output is written - // to Cloud Storage as JSON in the [Document] format. - rpc BatchProcessDocuments(BatchProcessRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*}:batchProcess" - body: "*" - additional_bindings { - post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:batchProcess" - body: "*" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "BatchProcessResponse" - metadata_type: "BatchProcessMetadata" - }; - } - - // Fetches processor types. Note that we do not use ListProcessorTypes here - // because it is not paginated. - rpc FetchProcessorTypes(FetchProcessorTypesRequest) returns (FetchProcessorTypesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}:fetchProcessorTypes" - }; - option (google.api.method_signature) = "parent"; - } - - // Lists the processor types that exist. - rpc ListProcessorTypes(ListProcessorTypesRequest) returns (ListProcessorTypesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/processorTypes" - }; - option (google.api.method_signature) = "parent"; - } - - // Lists all processors which belong to this project. - rpc ListProcessors(ListProcessorsRequest) returns (ListProcessorsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/processors" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a processor detail. - rpc GetProcessor(GetProcessorRequest) returns (Processor) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/processors/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Gets a processor version detail. - rpc GetProcessorVersion(GetProcessorVersionRequest) returns (ProcessorVersion) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all versions of a processor. - rpc ListProcessorVersions(ListProcessorVersionsRequest) returns (ListProcessorVersionsResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/processors/*}/processorVersions" - }; - option (google.api.method_signature) = "parent"; - } - - // Deletes the processor version, all artifacts under the processor version - // will be deleted. - rpc DeleteProcessorVersion(DeleteProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "DeleteProcessorVersionMetadata" - }; - } - - // Deploys the processor version. - rpc DeployProcessorVersion(DeployProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:deploy" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "DeployProcessorVersionResponse" - metadata_type: "DeployProcessorVersionMetadata" - }; - } - - // Undeploys the processor version. - rpc UndeployProcessorVersion(UndeployProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*/processorVersions/*}:undeploy" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "UndeployProcessorVersionResponse" - metadata_type: "UndeployProcessorVersionMetadata" - }; - } - - // Creates a processor from the type processor that the user chose. - // The processor will be at "ENABLED" state by default after its creation. - rpc CreateProcessor(CreateProcessorRequest) returns (Processor) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/processors" - body: "processor" - }; - option (google.api.method_signature) = "parent,processor"; - } - - // Deletes the processor, unloads all deployed model artifacts if it was - // enabled and then deletes all artifacts associated with this processor. - rpc DeleteProcessor(DeleteProcessorRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/processors/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "DeleteProcessorMetadata" - }; - } - - // Enables a processor - rpc EnableProcessor(EnableProcessorRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*}:enable" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "EnableProcessorResponse" - metadata_type: "EnableProcessorMetadata" - }; - } - - // Disables a processor - rpc DisableProcessor(DisableProcessorRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/processors/*}:disable" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "DisableProcessorResponse" - metadata_type: "DisableProcessorMetadata" - }; - } - - // Set the default (active) version of a [Processor][google.cloud.documentai.v1.Processor] that will be used in - // [ProcessDocument][google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument] and - // [BatchProcessDocuments][google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments]. - rpc SetDefaultProcessorVersion(SetDefaultProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{processor=projects/*/locations/*/processors/*}:setDefaultProcessorVersion" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "SetDefaultProcessorVersionResponse" - metadata_type: "SetDefaultProcessorVersionMetadata" - }; - } - - // Send a document for Human Review. The input document should be processed by - // the specified processor. - rpc ReviewDocument(ReviewDocumentRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/{human_review_config=projects/*/locations/*/processors/*/humanReviewConfig}:reviewDocument" - body: "*" - }; - option (google.api.method_signature) = "human_review_config"; - option (google.longrunning.operation_info) = { - response_type: "ReviewDocumentResponse" - metadata_type: "ReviewDocumentOperationMetadata" - }; - } -} - -// Request message for the process document method. -message ProcessRequest { - // The document payload. - oneof source { - // An inline document proto. - Document inline_document = 4; - - // A raw document content (bytes). - RawDocument raw_document = 5; - } - - // Required. The resource name of the [Processor][google.cloud.documentai.v1.Processor] or - // [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] - // to use for processing. If a [Processor][google.cloud.documentai.v1.Processor] is specified, the server will use - // its [default version][google.cloud.documentai.v1.Processor.default_processor_version]. Format: - // `projects/{project}/locations/{location}/processors/{processor}`, or - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "*" - } - ]; - - // Whether Human Review feature should be skipped for this request. Default to - // false. - bool skip_human_review = 3; - - // Specifies which fields to include in ProcessResponse's document. - // Only supports top level document and pages field so it must be in the form - // of `{document_field_name}` or `pages.{page_field_name}`. - google.protobuf.FieldMask field_mask = 6; -} - -// The status of human review on a processed document. -message HumanReviewStatus { - // The final state of human review on a processed document. - enum State { - // Human review state is unspecified. Most likely due to an internal error. - STATE_UNSPECIFIED = 0; - - // Human review is skipped for the document. This can happen because human - // review is not enabled on the processor or the processing request has - // been set to skip this document. - SKIPPED = 1; - - // Human review validation is triggered and passed, so no review is needed. - VALIDATION_PASSED = 2; - - // Human review validation is triggered and the document is under review. - IN_PROGRESS = 3; - - // Some error happened during triggering human review, see the - // [state_message] for details. - ERROR = 4; - } - - // The state of human review on the processing request. - State state = 1; - - // A message providing more details about the human review state. - string state_message = 2; - - // The name of the operation triggered by the processed document. This field - // is populated only when the [state] is [HUMAN_REVIEW_IN_PROGRESS]. It has - // the same response type and metadata as the long running operation returned - // by [ReviewDocument] method. - string human_review_operation = 3; -} - -// Response message for the process document method. -message ProcessResponse { - // The document payload, will populate fields based on the processor's - // behavior. - Document document = 1; - - // The status of human review on the processed document. - HumanReviewStatus human_review_status = 3; -} - -// Request message for batch process document method. -message BatchProcessRequest { - // Required. The resource name of [Processor][google.cloud.documentai.v1.Processor] or - // [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion]. - // Format: `projects/{project}/locations/{location}/processors/{processor}`, - // or - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "*" - } - ]; - - // The input documents for batch process. - BatchDocumentsInputConfig input_documents = 5; - - // The overall output config for batch process. - DocumentOutputConfig document_output_config = 6; - - // Whether Human Review feature should be skipped for this request. Default to - // false. - bool skip_human_review = 4; -} - -// Response message for batch process document method. -message BatchProcessResponse { - -} - -// The long running operation metadata for batch process method. -message BatchProcessMetadata { - // The status of a each individual document in the batch process. - message IndividualProcessStatus { - // The source of the document, same as the [input_gcs_source] field in the - // request when the batch process started. The batch process is started by - // take snapshot of that document, since a user can move or change that - // document during the process. - string input_gcs_source = 1; - - // The status processing the document. - google.rpc.Status status = 2; - - // The output_gcs_destination (in the request as `output_gcs_destination`) - // of the processed document if it was successful, otherwise empty. - string output_gcs_destination = 3; - - // The status of human review on the processed document. - HumanReviewStatus human_review_status = 5; - } - - // Possible states of the batch processing operation. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // Request operation is waiting for scheduling. - WAITING = 1; - - // Request is being processed. - RUNNING = 2; - - // The batch processing completed successfully. - SUCCEEDED = 3; - - // The batch processing was being cancelled. - CANCELLING = 4; - - // The batch processing was cancelled. - CANCELLED = 5; - - // The batch processing has failed. - FAILED = 6; - } - - // The state of the current batch processing. - State state = 1; - - // A message providing more details about the current state of processing. - // For example, the error message if the operation is failed. - string state_message = 2; - - // The creation time of the operation. - google.protobuf.Timestamp create_time = 3; - - // The last update time of the operation. - google.protobuf.Timestamp update_time = 4; - - // The list of response details of each document. - repeated IndividualProcessStatus individual_process_statuses = 5; -} - -// Request message for fetch processor types. -message FetchProcessorTypesRequest { - // Required. The project of processor type to list. - // The available processor types may depend on the allow-listing on projects. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/ProcessorType" - } - ]; -} - -// Response message for fetch processor types. -message FetchProcessorTypesResponse { - // The list of processor types. - repeated ProcessorType processor_types = 1; -} - -// Request message for list processor types. -message ListProcessorTypesRequest { - // Required. The location of processor type to list. - // The available processor types may depend on the allow-listing on projects. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/ProcessorType" - } - ]; - - // The maximum number of processor types to return. - // If unspecified, at most 100 processor types will be returned. - // The maximum value is 500; values above 500 will be coerced to 500. - int32 page_size = 2; - - // Used to retrieve the next page of results, empty if at the end of the list. - string page_token = 3; -} - -// Response message for list processor types. -message ListProcessorTypesResponse { - // The processor types. - repeated ProcessorType processor_types = 1; - - // Points to the next page, otherwise empty. - string next_page_token = 2; -} - -// Request message for list all processors belongs to a project. -message ListProcessorsRequest { - // Required. The parent (project and location) which owns this collection of Processors. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/Processor" - } - ]; - - // The maximum number of processors to return. - // If unspecified, at most 50 processors will be returned. - // The maximum value is 100; values above 100 will be coerced to 100. - int32 page_size = 2; - - // We will return the processors sorted by creation time. The page token - // will point to the next processor. - string page_token = 3; -} - -// Response message for list processors. -message ListProcessorsResponse { - // The list of processors. - repeated Processor processors = 1; - - // Points to the next processor, otherwise empty. - string next_page_token = 2; -} - -// Request message for get processor. -message GetProcessorRequest { - // Required. The processor resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// Request message for get processor version. -message GetProcessorVersionRequest { - // Required. The processor resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Request message for list all processor versions belongs to a processor. -message ListProcessorVersionsRequest { - // Required. The parent (project, location and processor) to list all versions. - // Format: `projects/{project}/locations/{location}/processors/{processor}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/ProcessorVersion" - } - ]; - - // The maximum number of processor versions to return. - // If unspecified, at most 10 processor versions will be returned. - // The maximum value is 20; values above 20 will be coerced to 20. - int32 page_size = 2; - - // We will return the processor versions sorted by creation time. The page - // token will point to the next processor version. - string page_token = 3; -} - -// Response message for list processors. -message ListProcessorVersionsResponse { - // The list of processors. - repeated ProcessorVersion processor_versions = 1; - - // Points to the next processor, otherwise empty. - string next_page_token = 2; -} - -// Request message for the delete processor version method. -message DeleteProcessorVersionRequest { - // Required. The processor version resource name to be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// The long running operation metadata for delete processor version method. -message DeleteProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for the deploy processor version method. -message DeployProcessorVersionRequest { - // Required. The processor version resource name to be deployed. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Response message for the deploy processor version method. -message DeployProcessorVersionResponse { - -} - -// The long running operation metadata for deploy processor version method. -message DeployProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for the undeploy processor version method. -message UndeployProcessorVersionRequest { - // Required. The processor version resource name to be undeployed. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Response message for the undeploy processor version method. -message UndeployProcessorVersionResponse { - -} - -// The long running operation metadata for the undeploy processor version -// method. -message UndeployProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for create a processor. Notice this request is sent to -// a regionalized backend service, and if the processor type is not available -// on that region, the creation will fail. -message CreateProcessorRequest { - // Required. The parent (project and location) under which to create the processor. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/Processor" - } - ]; - - // Required. The processor to be created, requires [processor_type] and [display_name] - // to be set. Also, the processor is under CMEK if CMEK fields are set. - Processor processor = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for the delete processor method. -message DeleteProcessorRequest { - // Required. The processor resource name to be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// The long running operation metadata for delete processor method. -message DeleteProcessorMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} - -// Request message for the enable processor method. -message EnableProcessorRequest { - // Required. The processor resource name to be enabled. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// Response message for the enable processor method. -// Intentionally empty proto for adding fields in future. -message EnableProcessorResponse { - -} - -// The long running operation metadata for enable processor method. -message EnableProcessorMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} - -// Request message for the disable processor method. -message DisableProcessorRequest { - // Required. The processor resource name to be disabled. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// Response message for the disable processor method. -// Intentionally empty proto for adding fields in future. -message DisableProcessorResponse { - -} - -// The long running operation metadata for disable processor method. -message DisableProcessorMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} - -// Request message for the set default processor version method. -message SetDefaultProcessorVersionRequest { - // Required. The resource name of the [Processor][google.cloud.documentai.v1.Processor] to change default version. - string processor = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; - - // Required. The resource name of child [ProcessorVersion][google.cloud.documentai.v1.ProcessorVersion] to use as default. - // Format: - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` - string default_processor_version = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Response message for set default processor version method. -message SetDefaultProcessorVersionResponse { - -} - -// The long running operation metadata for set default processor version -// method. -message SetDefaultProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for review document method. -message ReviewDocumentRequest { - // The priority level of the human review task. - enum Priority { - // The default priority level. - DEFAULT = 0; - - // The urgent priority level. The labeling manager should allocate labeler - // resource to the urgent task queue to respect this priority level. - URGENT = 1; - } - - // The document payload. - oneof source { - // An inline document proto. - Document inline_document = 4; - } - - // Required. The resource name of the HumanReviewConfig that the document will be - // reviewed with. - string human_review_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/HumanReviewConfig" - } - ]; - - // Whether the validation should be performed on the ad-hoc review request. - bool enable_schema_validation = 3; - - // The priority of the human review task. - Priority priority = 5; - - // The document schema of the human review task. - DocumentSchema document_schema = 6; -} - -// Response message for review document method. -message ReviewDocumentResponse { - // Possible states of the review operation. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // The review operation is rejected by the reviewer. - REJECTED = 1; - - // The review operation is succeeded. - SUCCEEDED = 2; - } - - // The Cloud Storage uri for the human reviewed document if the review is - // succeeded. - string gcs_destination = 1; - - // The state of the review operation. - State state = 2; - - // The reason why the review is rejected by reviewer. - string rejection_reason = 3; -} - -// The long running operation metadata for review document method. -message ReviewDocumentOperationMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; - - // The Crowd Compute question ID. - string question_id = 6; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_schema.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_schema.proto deleted file mode 100644 index ceb25a1d69a..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/document_schema.proto +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiDocumentSchema"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// The schema defines the output of the processed document by a processor. -message DocumentSchema { - // EntityType is the wrapper of a label of the corresponding model with - // detailed attributes and limitations for entity-based processors. Multiple - // types can also compose a dependency tree to represent nested types. - message EntityType { - // Defines the a list of enum values. - message EnumValues { - // The individual values that this enum values type can include. - repeated string values = 1; - } - - // Defines properties that can be part of the entity type. - message Property { - // Types of occurrences of the entity type in the document. Note: this - // represents the number of instances of an entity types, not number of - // mentions of a given entity instance. - enum OccurrenceType { - // Unspecified occurrence type. - OCCURRENCE_TYPE_UNSPECIFIED = 0; - - // There will be zero or one instance of this entity type. - OPTIONAL_ONCE = 1; - - // The entity type will appear zero or multiple times. - OPTIONAL_MULTIPLE = 2; - - // The entity type will only appear exactly once. - REQUIRED_ONCE = 3; - - // The entity type will appear once or more times. - REQUIRED_MULTIPLE = 4; - } - - // The name of the property. Follows the same guidelines as the - // EntityType name. - string name = 1; - - // A reference to the value type of the property. This type is subject - // to the same conventions as the `Entity.base_types` field. - string value_type = 2; - - // Occurrence type limits the number of instances an entity type appears - // in the document. - OccurrenceType occurrence_type = 3; - } - - oneof value_source { - // If specified, lists all the possible values for this entity. This - // should not be more than a handful of values. If the number of values - // is >10 or could change frequently use the `EntityType.value_ontology` - // field and specify a list of all possible values in a value ontology - // file. - EnumValues enum_values = 14; - } - - // User defined name for the type. - string display_name = 13; - - // Name of the type. It must be unique within the schema file and - // cannot be a 'Common Type'. Besides that we use the following naming - // conventions: - // - // - *use `snake_casing`* - // - name matching is case-insensitive - // - Maximum 64 characters. - // - Must start with a letter. - // - Allowed characters: ASCII letters `[a-z0-9_-]`. (For backward - // compatibility internal infrastructure and tooling can handle any ascii - // character) - // - The `/` is sometimes used to denote a property of a type. For example - // `line_item/amount`. This convention is deprecated, but will still be - // honored for backward compatibility. - string name = 1; - - // The entity type that this type is derived from. For now, one and only - // one should be set. - repeated string base_types = 2; - - // Describing the nested structure, or composition of an entity. - repeated Property properties = 6; - } - - // Metadata for global schema behavior. - message Metadata { - // If true, a `document` entity type can be applied to subdocument ( - // splitting). Otherwise, it can only be applied to the entire document - // (classification). - bool document_splitter = 1; - - // If true, on a given page, there can be multiple `document` annotations - // covering it. - bool document_allow_multiple_labels = 2; - - // If set, all the nested entities must be prefixed with the parents. - bool prefixed_naming_on_properties = 6; - - // If set, we will skip the naming format validation in the schema. So the - // string values in `DocumentSchema.EntityType.name` and - // `DocumentSchema.EntityType.Property.name` will not be checked. - bool skip_naming_validation = 7; - } - - // Display name to show to users. - string display_name = 1; - - // Description of the schema. - string description = 2; - - // Entity types of the schema. - repeated EntityType entity_types = 3; - - // Metadata of the schema. - Metadata metadata = 4; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/geometry.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/geometry.proto deleted file mode 100644 index 7471ef01247..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/geometry.proto +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "GeometryProto"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// A vertex represents a 2D point in the image. -// NOTE: the vertex coordinates are in the same scale as the original image. -message Vertex { - // X coordinate. - int32 x = 1; - - // Y coordinate (starts from the top of the image). - int32 y = 2; -} - -// A vertex represents a 2D point in the image. -// NOTE: the normalized vertex coordinates are relative to the original image -// and range from 0 to 1. -message NormalizedVertex { - // X coordinate. - float x = 1; - - // Y coordinate (starts from the top of the image). - float y = 2; -} - -// A bounding polygon for the detected image annotation. -message BoundingPoly { - // The bounding polygon vertices. - repeated Vertex vertices = 1; - - // The bounding polygon normalized vertices. - repeated NormalizedVertex normalized_vertices = 2; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/operation_metadata.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/operation_metadata.proto deleted file mode 100644 index 5698b0a4f3c..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/operation_metadata.proto +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "OperationMetadataProto"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// The common metadata for long running operations. -message CommonOperationMetadata { - // State of the longrunning operation. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // Operation is still running. - RUNNING = 1; - - // Operation is being cancelled. - CANCELLING = 2; - - // Operation succeeded. - SUCCEEDED = 3; - - // Operation failed. - FAILED = 4; - - // Operation is cancelled. - CANCELLED = 5; - } - - // The state of the operation. - State state = 1; - - // A message providing more details about the current state of processing. - string state_message = 2; - - // A related resource to this operation. - string resource = 5; - - // The creation time of the operation. - google.protobuf.Timestamp create_time = 3; - - // The last update time of the operation. - google.protobuf.Timestamp update_time = 4; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor.proto deleted file mode 100644 index 3ffe6927df9..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor.proto +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/documentai/v1/document_schema.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProcessor"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// A processor version is an implementation of a processor. Each processor -// can have multiple versions, pre-trained by Google internally or up-trained -// by the customer. At a time, a processor can only have one default version -// version. So the processor's behavior (when processing documents) is defined -// by a default version -message ProcessorVersion { - option (google.api.resource) = { - type: "documentai.googleapis.com/ProcessorVersion" - pattern: "projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}" - }; - - // Information about the upcoming deprecation of this processor version. - message DeprecationInfo { - // The time at which this processor version will be deprecated. - google.protobuf.Timestamp deprecation_time = 1; - - // If set, the processor version that will be used as a replacement. - string replacement_processor_version = 2 [(google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - }]; - } - - // The possible states of the processor version. - enum State { - // The processor version is in an unspecified state. - STATE_UNSPECIFIED = 0; - - // The processor version is deployed and can be used for processing. - DEPLOYED = 1; - - // The processor version is being deployed. - DEPLOYING = 2; - - // The processor version is not deployed and cannot be used for processing. - UNDEPLOYED = 3; - - // The processor version is being undeployed. - UNDEPLOYING = 4; - - // The processor version is being created. - CREATING = 5; - - // The processor version is being deleted. - DELETING = 6; - - // The processor version failed and is in an indeterminate state. - FAILED = 7; - } - - // The resource name of the processor version. - // Format: - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}` - string name = 1; - - // The display name of the processor version. - string display_name = 2; - - // The schema of the processor version. Describes the output. - DocumentSchema document_schema = 12; - - // The state of the processor version. - State state = 6; - - // The time the processor version was created. - google.protobuf.Timestamp create_time = 7; - - // The KMS key name used for encryption. - string kms_key_name = 9; - - // The KMS key version with which data is encrypted. - string kms_key_version_name = 10; - - // Denotes that this ProcessorVersion is managed by google. - bool google_managed = 11; - - // If set, information about the eventual deprecation of this version. - DeprecationInfo deprecation_info = 13; -} - -// The first-class citizen for Document AI. Each processor defines how to -// extract structural information from a document. -message Processor { - option (google.api.resource) = { - type: "documentai.googleapis.com/Processor" - pattern: "projects/{project}/locations/{location}/processors/{processor}" - }; - - // The possible states of the processor. - enum State { - // The processor is in an unspecified state. - STATE_UNSPECIFIED = 0; - - // The processor is enabled, i.e., has an enabled version which can - // currently serve processing requests and all the feature dependencies have - // been successfully initialized. - ENABLED = 1; - - // The processor is disabled. - DISABLED = 2; - - // The processor is being enabled, will become `ENABLED` if successful. - ENABLING = 3; - - // The processor is being disabled, will become `DISABLED` if successful. - DISABLING = 4; - - // The processor is being created, will become either `ENABLED` (for - // successful creation) or `FAILED` (for failed ones). - // Once a processor is in this state, it can then be used for document - // processing, but the feature dependencies of the processor might not be - // fully created yet. - CREATING = 5; - - // The processor failed during creation or initialization of feature - // dependencies. The user should delete the processor and recreate one as - // all the functionalities of the processor are disabled. - FAILED = 6; - - // The processor is being deleted, will be removed if successful. - DELETING = 7; - } - - // Output only. Immutable. The resource name of the processor. - // Format: `projects/{project}/locations/{location}/processors/{processor}` - string name = 1 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. - // To get a list of processors types, see - // [FetchProcessorTypes][google.cloud.documentai.v1.DocumentProcessorService.FetchProcessorTypes]. - string type = 2; - - // The display name of the processor. - string display_name = 3; - - // Output only. The state of the processor. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The default processor version. - string default_processor_version = 9 [(google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - }]; - - // Output only. Immutable. The http endpoint that can be called to invoke processing. - string process_endpoint = 6 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.field_behavior) = IMMUTABLE - ]; - - // The time the processor was created. - google.protobuf.Timestamp create_time = 7; - - // The KMS key used for encryption/decryption in CMEK scenarios. - // See https://cloud.google.com/security-key-management. - string kms_key_name = 8; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor_type.proto b/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor_type.proto deleted file mode 100644 index 2c9ee923051..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/protos/google/cloud/documentai/v1/processor_type.proto +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1; - -import "google/api/launch_stage.proto"; -import "google/api/resource.proto"; - -option csharp_namespace = "Google.Cloud.DocumentAI.V1"; -option go_package = "google.golang.org/genproto/googleapis/cloud/documentai/v1;documentai"; -option java_multiple_files = true; -option java_outer_classname = "DocumentAiProcessorType"; -option java_package = "com.google.cloud.documentai.v1"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1"; -option ruby_package = "Google::Cloud::DocumentAI::V1"; - -// A processor type is responsible for performing a certain document -// understanding task on a certain type of document. -message ProcessorType { - option (google.api.resource) = { - type: "documentai.googleapis.com/ProcessorType" - pattern: "projects/{project}/locations/{location}/processorTypes/{processor_type}" - }; - - // The location information about where the processor is available. - message LocationInfo { - // The location id, currently must be one of [us, eu]. - string location_id = 1; - } - - // The resource name of the processor type. - // Format: `projects/{project}/processorTypes/{processor_type}` - string name = 1; - - // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. - string type = 2; - - // The processor category, used by UI to group processor types. - string category = 3; - - // The locations in which this processor is available. - repeated LocationInfo available_locations = 4; - - // Whether the processor type allows creation. If true, users can create a - // processor of this processor type. Otherwise, users need to request access. - bool allow_creation = 6; - - // Launch stage of the processor type - google.api.LaunchStage launch_stage = 8; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.batch_process_documents.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.batch_process_documents.js deleted file mode 100644 index c099efd7b6c..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.batch_process_documents.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of Processor google.cloud.documentai.v1.Processor or - * ProcessorVersion google.cloud.documentai.v1.ProcessorVersion. - * Format: `projects/{project}/locations/{location}/processors/{processor}`, - * or - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - */ - // const name = 'abc123' - /** - * The input documents for batch process. - */ - // const inputDocuments = {} - /** - * The overall output config for batch process. - */ - // const documentOutputConfig = {} - /** - * Whether Human Review feature should be skipped for this request. Default to - * false. - */ - // const skipHumanReview = true - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callBatchProcessDocuments() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.batchProcessDocuments(request); - const [response] = await operation.promise(); - console.log(response); - } - - callBatchProcessDocuments(); - // [END documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.create_processor.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.create_processor.js deleted file mode 100644 index 24da55f864f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.create_processor.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, processor) { - // [START documentai_v1_generated_DocumentProcessorService_CreateProcessor_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent (project and location) under which to create the processor. - * Format: `projects/{project}/locations/{location}` - */ - // const parent = 'abc123' - /** - * 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. - */ - // const processor = {} - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callCreateProcessor() { - // Construct request - const request = { - parent, - processor, - }; - - // Run request - const response = await documentaiClient.createProcessor(request); - console.log(response); - } - - callCreateProcessor(); - // [END documentai_v1_generated_DocumentProcessorService_CreateProcessor_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor.js deleted file mode 100644 index 2c087b70d5b..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1_generated_DocumentProcessorService_DeleteProcessor_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor resource name to be deleted. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callDeleteProcessor() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.deleteProcessor(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteProcessor(); - // [END documentai_v1_generated_DocumentProcessorService_DeleteProcessor_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor_version.js deleted file mode 100644 index 2f19c69d877..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.delete_processor_version.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1_generated_DocumentProcessorService_DeleteProcessorVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor version resource name to be deleted. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callDeleteProcessorVersion() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.deleteProcessorVersion(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteProcessorVersion(); - // [END documentai_v1_generated_DocumentProcessorService_DeleteProcessorVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.deploy_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.deploy_processor_version.js deleted file mode 100644 index 09379736014..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.deploy_processor_version.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1_generated_DocumentProcessorService_DeployProcessorVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor version resource name to be deployed. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callDeployProcessorVersion() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.deployProcessorVersion(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeployProcessorVersion(); - // [END documentai_v1_generated_DocumentProcessorService_DeployProcessorVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.disable_processor.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.disable_processor.js deleted file mode 100644 index 80a52d09a2e..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.disable_processor.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1_generated_DocumentProcessorService_DisableProcessor_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor resource name to be disabled. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callDisableProcessor() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.disableProcessor(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDisableProcessor(); - // [END documentai_v1_generated_DocumentProcessorService_DisableProcessor_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.enable_processor.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.enable_processor.js deleted file mode 100644 index 8d66f45c069..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.enable_processor.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1_generated_DocumentProcessorService_EnableProcessor_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor resource name to be enabled. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callEnableProcessor() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.enableProcessor(request); - const [response] = await operation.promise(); - console.log(response); - } - - callEnableProcessor(); - // [END documentai_v1_generated_DocumentProcessorService_EnableProcessor_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.fetch_processor_types.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.fetch_processor_types.js deleted file mode 100644 index 5bb5c2383e4..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.fetch_processor_types.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START documentai_v1_generated_DocumentProcessorService_FetchProcessorTypes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - */ - // const parent = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callFetchProcessorTypes() { - // Construct request - const request = { - parent, - }; - - // Run request - const response = await documentaiClient.fetchProcessorTypes(request); - console.log(response); - } - - callFetchProcessorTypes(); - // [END documentai_v1_generated_DocumentProcessorService_FetchProcessorTypes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor.js deleted file mode 100644 index 91913575c66..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1_generated_DocumentProcessorService_GetProcessor_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor resource name. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callGetProcessor() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await documentaiClient.getProcessor(request); - console.log(response); - } - - callGetProcessor(); - // [END documentai_v1_generated_DocumentProcessorService_GetProcessor_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor_version.js deleted file mode 100644 index 31bcc81a04f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.get_processor_version.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1_generated_DocumentProcessorService_GetProcessorVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor resource name. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callGetProcessorVersion() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await documentaiClient.getProcessorVersion(request); - console.log(response); - } - - callGetProcessorVersion(); - // [END documentai_v1_generated_DocumentProcessorService_GetProcessorVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_types.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_types.js deleted file mode 100644 index a900fd1e249..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_types.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START documentai_v1_generated_DocumentProcessorService_ListProcessorTypes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - */ - // const parent = 'abc123' - /** - * The maximum number of processor types to return. - * If unspecified, at most 100 processor types will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - */ - // const pageSize = 1234 - /** - * Used to retrieve the next page of results, empty if at the end of the list. - */ - // const pageToken = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callListProcessorTypes() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await documentaiClient.listProcessorTypesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProcessorTypes(); - // [END documentai_v1_generated_DocumentProcessorService_ListProcessorTypes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_versions.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_versions.js deleted file mode 100644 index 490c0fb5038..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processor_versions.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START documentai_v1_generated_DocumentProcessorService_ListProcessorVersions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent (project, location and processor) to list all versions. - * Format: `projects/{project}/locations/{location}/processors/{processor}` - */ - // const parent = 'abc123' - /** - * The maximum number of processor versions to return. - * If unspecified, at most 10 processor versions will be returned. - * The maximum value is 20; values above 20 will be coerced to 20. - */ - // const pageSize = 1234 - /** - * We will return the processor versions sorted by creation time. The page - * token will point to the next processor version. - */ - // const pageToken = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callListProcessorVersions() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await documentaiClient.listProcessorVersionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProcessorVersions(); - // [END documentai_v1_generated_DocumentProcessorService_ListProcessorVersions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processors.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processors.js deleted file mode 100644 index 62b63c5ce60..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.list_processors.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START documentai_v1_generated_DocumentProcessorService_ListProcessors_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent (project and location) which owns this collection of Processors. - * Format: `projects/{project}/locations/{location}` - */ - // const parent = 'abc123' - /** - * 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. - */ - // const pageSize = 1234 - /** - * We will return the processors sorted by creation time. The page token - * will point to the next processor. - */ - // const pageToken = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callListProcessors() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await documentaiClient.listProcessorsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProcessors(); - // [END documentai_v1_generated_DocumentProcessorService_ListProcessors_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.process_document.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.process_document.js deleted file mode 100644 index dfcb92d5a7d..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.process_document.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1_generated_DocumentProcessorService_ProcessDocument_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * An inline document proto. - */ - // const inlineDocument = {} - /** - * A raw document content (bytes). - */ - // const rawDocument = {} - /** - * Required. The resource name of the Processor google.cloud.documentai.v1.Processor or - * ProcessorVersion google.cloud.documentai.v1.ProcessorVersion - * to use for processing. If a Processor google.cloud.documentai.v1.Processor is specified, the server will use - * its default version google.cloud.documentai.v1.Processor.default_processor_version. Format: - * `projects/{project}/locations/{location}/processors/{processor}`, or - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - */ - // const name = 'abc123' - /** - * Whether Human Review feature should be skipped for this request. Default to - * false. - */ - // const skipHumanReview = true - /** - * Specifies which fields to include in ProcessResponse's document. - * Only supports top level document and pages field so it must be in the form - * of `{document_field_name}` or `pages.{page_field_name}`. - */ - // const fieldMask = {} - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callProcessDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await documentaiClient.processDocument(request); - console.log(response); - } - - callProcessDocument(); - // [END documentai_v1_generated_DocumentProcessorService_ProcessDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.review_document.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.review_document.js deleted file mode 100644 index 583b5a9b150..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.review_document.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(humanReviewConfig) { - // [START documentai_v1_generated_DocumentProcessorService_ReviewDocument_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * An inline document proto. - */ - // const inlineDocument = {} - /** - * Required. The resource name of the HumanReviewConfig that the document will be - * reviewed with. - */ - // const humanReviewConfig = 'abc123' - /** - * Whether the validation should be performed on the ad-hoc review request. - */ - // const enableSchemaValidation = true - /** - * The priority of the human review task. - */ - // const priority = {} - /** - * The document schema of the human review task. - */ - // const documentSchema = {} - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callReviewDocument() { - // Construct request - const request = { - humanReviewConfig, - }; - - // Run request - const [operation] = await documentaiClient.reviewDocument(request); - const [response] = await operation.promise(); - console.log(response); - } - - callReviewDocument(); - // [END documentai_v1_generated_DocumentProcessorService_ReviewDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.set_default_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.set_default_processor_version.js deleted file mode 100644 index 64556b986f5..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.set_default_processor_version.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(processor, defaultProcessorVersion) { - // [START documentai_v1_generated_DocumentProcessorService_SetDefaultProcessorVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Processor google.cloud.documentai.v1.Processor to change default version. - */ - // const processor = 'abc123' - /** - * Required. The resource name of child ProcessorVersion google.cloud.documentai.v1.ProcessorVersion to use as default. - * Format: - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` - */ - // const defaultProcessorVersion = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callSetDefaultProcessorVersion() { - // Construct request - const request = { - processor, - defaultProcessorVersion, - }; - - // Run request - const [operation] = await documentaiClient.setDefaultProcessorVersion(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetDefaultProcessorVersion(); - // [END documentai_v1_generated_DocumentProcessorService_SetDefaultProcessorVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.undeploy_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.undeploy_processor_version.js deleted file mode 100644 index 5c84587ee7b..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/document_processor_service.undeploy_processor_version.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1_generated_DocumentProcessorService_UndeployProcessorVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor version resource name to be undeployed. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callUndeployProcessorVersion() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.undeployProcessorVersion(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUndeployProcessorVersion(); - // [END documentai_v1_generated_DocumentProcessorService_UndeployProcessorVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/snippet_metadata.google.cloud.documentai.v1.json b/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/snippet_metadata.google.cloud.documentai.v1.json deleted file mode 100644 index 2293cffa613..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/samples/generated/v1/snippet_metadata.google.cloud.documentai.v1.json +++ /dev/null @@ -1,771 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-documentai", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.documentai.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_ProcessDocument_async", - "title": "DocumentProcessorService processDocument Sample", - "origin": "API_DEFINITION", - "description": " Processes a single document.", - "canonical": true, - "file": "document_processor_service.process_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 77, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ProcessDocument", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument", - "async": true, - "parameters": [ - { - "name": "inline_document", - "type": ".google.cloud.documentai.v1.Document" - }, - { - "name": "raw_document", - "type": ".google.cloud.documentai.v1.RawDocument" - }, - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "skip_human_review", - "type": "TYPE_BOOL" - }, - { - "name": "field_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.documentai.v1.ProcessResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ProcessDocument", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async", - "title": "DocumentProcessorService batchProcessDocuments Sample", - "origin": "API_DEFINITION", - "description": " LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.", - "canonical": true, - "file": "document_processor_service.batch_process_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchProcessDocuments", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "input_documents", - "type": ".google.cloud.documentai.v1.BatchDocumentsInputConfig" - }, - { - "name": "document_output_config", - "type": ".google.cloud.documentai.v1.DocumentOutputConfig" - }, - { - "name": "skip_human_review", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "BatchProcessDocuments", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_FetchProcessorTypes_async", - "title": "DocumentProcessorService fetchProcessorTypes Sample", - "origin": "API_DEFINITION", - "description": " Fetches processor types. Note that we do not use ListProcessorTypes here because it is not paginated.", - "canonical": true, - "file": "document_processor_service.fetch_processor_types.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "FetchProcessorTypes", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.FetchProcessorTypes", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1.FetchProcessorTypesResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "FetchProcessorTypes", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.FetchProcessorTypes", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_ListProcessorTypes_async", - "title": "DocumentProcessorService listProcessorTypes Sample", - "origin": "API_DEFINITION", - "description": " Lists the processor types that exist.", - "canonical": true, - "file": "document_processor_service.list_processor_types.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProcessorTypes", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessorTypes", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1.ListProcessorTypesResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ListProcessorTypes", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessorTypes", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_ListProcessors_async", - "title": "DocumentProcessorService listProcessors Sample", - "origin": "API_DEFINITION", - "description": " Lists all processors which belong to this project.", - "canonical": true, - "file": "document_processor_service.list_processors.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProcessors", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessors", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1.ListProcessorsResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ListProcessors", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessors", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_GetProcessor_async", - "title": "DocumentProcessorService getProcessor Sample", - "origin": "API_DEFINITION", - "description": " Gets a processor detail.", - "canonical": true, - "file": "document_processor_service.get_processor.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProcessor", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.GetProcessor", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1.Processor", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "GetProcessor", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.GetProcessor", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_GetProcessorVersion_async", - "title": "DocumentProcessorService getProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Gets a processor version detail.", - "canonical": true, - "file": "document_processor_service.get_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProcessorVersion", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.GetProcessorVersion", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1.ProcessorVersion", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "GetProcessorVersion", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.GetProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_ListProcessorVersions_async", - "title": "DocumentProcessorService listProcessorVersions Sample", - "origin": "API_DEFINITION", - "description": " Lists all versions of a processor.", - "canonical": true, - "file": "document_processor_service.list_processor_versions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProcessorVersions", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessorVersions", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1.ListProcessorVersionsResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ListProcessorVersions", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ListProcessorVersions", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_DeleteProcessorVersion_async", - "title": "DocumentProcessorService deleteProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Deletes the processor version, all artifacts under the processor version will be deleted.", - "canonical": true, - "file": "document_processor_service.delete_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProcessorVersion", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeleteProcessorVersion", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "DeleteProcessorVersion", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeleteProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_DeployProcessorVersion_async", - "title": "DocumentProcessorService deployProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Deploys the processor version.", - "canonical": true, - "file": "document_processor_service.deploy_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeployProcessorVersion", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeployProcessorVersion", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "DeployProcessorVersion", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeployProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_UndeployProcessorVersion_async", - "title": "DocumentProcessorService undeployProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Undeploys the processor version.", - "canonical": true, - "file": "document_processor_service.undeploy_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UndeployProcessorVersion", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.UndeployProcessorVersion", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "UndeployProcessorVersion", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.UndeployProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_CreateProcessor_async", - "title": "DocumentProcessorService createProcessor Sample", - "origin": "API_DEFINITION", - "description": " Creates a processor from the type processor that the user chose. The processor will be at \"ENABLED\" state by default after its creation.", - "canonical": true, - "file": "document_processor_service.create_processor.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProcessor", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.CreateProcessor", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "processor", - "type": ".google.cloud.documentai.v1.Processor" - } - ], - "resultType": ".google.cloud.documentai.v1.Processor", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "CreateProcessor", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.CreateProcessor", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_DeleteProcessor_async", - "title": "DocumentProcessorService deleteProcessor Sample", - "origin": "API_DEFINITION", - "description": " Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.", - "canonical": true, - "file": "document_processor_service.delete_processor.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProcessor", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeleteProcessor", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "DeleteProcessor", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DeleteProcessor", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_EnableProcessor_async", - "title": "DocumentProcessorService enableProcessor Sample", - "origin": "API_DEFINITION", - "description": " Enables a processor", - "canonical": true, - "file": "document_processor_service.enable_processor.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "EnableProcessor", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.EnableProcessor", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "EnableProcessor", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.EnableProcessor", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_DisableProcessor_async", - "title": "DocumentProcessorService disableProcessor Sample", - "origin": "API_DEFINITION", - "description": " Disables a processor", - "canonical": true, - "file": "document_processor_service.disable_processor.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DisableProcessor", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DisableProcessor", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "DisableProcessor", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.DisableProcessor", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_SetDefaultProcessorVersion_async", - "title": "DocumentProcessorService setDefaultProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Set the default (active) version of a [Processor][google.cloud.documentai.v1.Processor] that will be used in [ProcessDocument][google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument] and [BatchProcessDocuments][google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments].", - "canonical": true, - "file": "document_processor_service.set_default_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetDefaultProcessorVersion", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.SetDefaultProcessorVersion", - "async": true, - "parameters": [ - { - "name": "processor", - "type": "TYPE_STRING" - }, - { - "name": "default_processor_version", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "SetDefaultProcessorVersion", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.SetDefaultProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1_generated_DocumentProcessorService_ReviewDocument_async", - "title": "DocumentProcessorService reviewDocument Sample", - "origin": "API_DEFINITION", - "description": " Send a document for Human Review. The input document should be processed by the specified processor.", - "canonical": true, - "file": "document_processor_service.review_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReviewDocument", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ReviewDocument", - "async": true, - "parameters": [ - { - "name": "inline_document", - "type": ".google.cloud.documentai.v1.Document" - }, - { - "name": "human_review_config", - "type": "TYPE_STRING" - }, - { - "name": "enable_schema_validation", - "type": "TYPE_BOOL" - }, - { - "name": "priority", - "type": ".google.cloud.documentai.v1.ReviewDocumentRequest.Priority" - }, - { - "name": "document_schema", - "type": ".google.cloud.documentai.v1.DocumentSchema" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ReviewDocument", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService.ReviewDocument", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1.DocumentProcessorService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1/src/index.ts deleted file mode 100644 index a59bbb62811..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const 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/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts deleted file mode 100644 index 8f4d9430dd2..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client.ts +++ /dev/null @@ -1,2763 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/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'; -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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new DocumentProcessorServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - processorVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}' - ), - 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 = { - listProcessorTypes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processorTypes'), - listProcessors: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processors'), - listProcessorVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processorVersions') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',additional_bindings: [{get: '/uiv1beta3/{name=projects/*/locations/*}',}], - },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',additional_bindings: [{get: '/uiv1beta3/{name=projects/*}/locations',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',additional_bindings: [{post: '/uiv1beta3/{name=projects/*/locations/*/operations/*}:cancel',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/operations/*}',additional_bindings: [{get: '/v1/{name=projects/*/locations/*/operations/*}',},{get: '/uiv1beta3/{name=projects/*/locations/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*/operations}',additional_bindings: [{get: '/uiv1beta3/{name=projects/*/locations/*/operations}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 deleteProcessorVersionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteProcessorVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.DeleteProcessorVersionMetadata') as gax.protobuf.Type; - const deployProcessorVersionResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.DeployProcessorVersionResponse') as gax.protobuf.Type; - const deployProcessorVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.DeployProcessorVersionMetadata') as gax.protobuf.Type; - const undeployProcessorVersionResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.UndeployProcessorVersionResponse') as gax.protobuf.Type; - const undeployProcessorVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.UndeployProcessorVersionMetadata') as gax.protobuf.Type; - const deleteProcessorResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteProcessorMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.DeleteProcessorMetadata') as gax.protobuf.Type; - const enableProcessorResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.EnableProcessorResponse') as gax.protobuf.Type; - const enableProcessorMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.EnableProcessorMetadata') as gax.protobuf.Type; - const disableProcessorResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.DisableProcessorResponse') as gax.protobuf.Type; - const disableProcessorMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.DisableProcessorMetadata') as gax.protobuf.Type; - const setDefaultProcessorVersionResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.SetDefaultProcessorVersionResponse') as gax.protobuf.Type; - const setDefaultProcessorVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1.SetDefaultProcessorVersionMetadata') 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)), - deleteProcessorVersion: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteProcessorVersionResponse.decode.bind(deleteProcessorVersionResponse), - deleteProcessorVersionMetadata.decode.bind(deleteProcessorVersionMetadata)), - deployProcessorVersion: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deployProcessorVersionResponse.decode.bind(deployProcessorVersionResponse), - deployProcessorVersionMetadata.decode.bind(deployProcessorVersionMetadata)), - undeployProcessorVersion: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - undeployProcessorVersionResponse.decode.bind(undeployProcessorVersionResponse), - undeployProcessorVersionMetadata.decode.bind(undeployProcessorVersionMetadata)), - 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)), - setDefaultProcessorVersion: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setDefaultProcessorVersionResponse.decode.bind(setDefaultProcessorVersionResponse), - setDefaultProcessorVersionMetadata.decode.bind(setDefaultProcessorVersionMetadata)), - 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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', 'fetchProcessorTypes', 'listProcessorTypes', 'listProcessors', 'getProcessor', 'getProcessorVersion', 'listProcessorVersions', 'deleteProcessorVersion', 'deployProcessorVersion', 'undeployProcessorVersion', 'createProcessor', 'deleteProcessor', 'enableProcessor', 'disableProcessor', 'setDefaultProcessorVersion', '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._opts.fallback - ); - - 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 -- - // ------------------- -/** - * 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 resource name of the {@link google.cloud.documentai.v1.Processor|Processor} or - * {@link google.cloud.documentai.v1.ProcessorVersion|ProcessorVersion} - * to use for processing. If a {@link google.cloud.documentai.v1.Processor|Processor} is specified, the server will use - * its {@link google.cloud.documentai.v1.Processor.default_processor_version|default version}. Format: - * `projects/{project}/locations/{location}/processors/{processor}`, or - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - * @param {boolean} request.skipHumanReview - * Whether Human Review feature should be skipped for this request. Default to - * false. - * @param {google.protobuf.FieldMask} request.fieldMask - * Specifies which fields to include in ProcessResponse's document. - * Only supports top level document and pages field so it must be in the form - * of `{document_field_name}` or `pages.{page_field_name}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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 include:samples/generated/v1/document_processor_service.process_document.js - * region_tag:documentai_v1_generated_DocumentProcessorService_ProcessDocument_async - */ - 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; - 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.processDocument(request, options, callback); - } -/** - * Fetches processor types. Note that we do not use ListProcessorTypes here - * because it is not paginated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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.v1.FetchProcessorTypesResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.fetch_processor_types.js - * region_tag:documentai_v1_generated_DocumentProcessorService_FetchProcessorTypes_async - */ - fetchProcessorTypes( - request?: protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest|undefined, {}|undefined - ]>; - fetchProcessorTypes( - request: protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest|null|undefined, - {}|null|undefined>): void; - fetchProcessorTypes( - request: protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest, - callback: Callback< - protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest|null|undefined, - {}|null|undefined>): void; - fetchProcessorTypes( - request?: protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1.IFetchProcessorTypesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse, - protos.google.cloud.documentai.v1.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.fetchProcessorTypes(request, options, callback); - } -/** - * Gets a processor detail. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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.v1.Processor}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.get_processor.js - * region_tag:documentai_v1_generated_DocumentProcessorService_GetProcessor_async - */ - getProcessor( - request?: protos.google.cloud.documentai.v1.IGetProcessorRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.IGetProcessorRequest|undefined, {}|undefined - ]>; - getProcessor( - request: protos.google.cloud.documentai.v1.IGetProcessorRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.IGetProcessorRequest|null|undefined, - {}|null|undefined>): void; - getProcessor( - request: protos.google.cloud.documentai.v1.IGetProcessorRequest, - callback: Callback< - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.IGetProcessorRequest|null|undefined, - {}|null|undefined>): void; - getProcessor( - request?: protos.google.cloud.documentai.v1.IGetProcessorRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.IGetProcessorRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.IGetProcessorRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.IGetProcessorRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProcessor(request, options, callback); - } -/** - * Gets a processor version detail. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProcessorVersion]{@link google.cloud.documentai.v1.ProcessorVersion}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.get_processor_version.js - * region_tag:documentai_v1_generated_DocumentProcessorService_GetProcessorVersion_async - */ - getProcessorVersion( - request?: protos.google.cloud.documentai.v1.IGetProcessorVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1.IProcessorVersion, - protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|undefined, {}|undefined - ]>; - getProcessorVersion( - request: protos.google.cloud.documentai.v1.IGetProcessorVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1.IProcessorVersion, - protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|null|undefined, - {}|null|undefined>): void; - getProcessorVersion( - request: protos.google.cloud.documentai.v1.IGetProcessorVersionRequest, - callback: Callback< - protos.google.cloud.documentai.v1.IProcessorVersion, - protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|null|undefined, - {}|null|undefined>): void; - getProcessorVersion( - request?: protos.google.cloud.documentai.v1.IGetProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1.IProcessorVersion, - protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1.IProcessorVersion, - protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1.IProcessorVersion, - protos.google.cloud.documentai.v1.IGetProcessorVersionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProcessorVersion(request, options, callback); - } -/** - * 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.v1.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.v1.Processor}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.create_processor.js - * region_tag:documentai_v1_generated_DocumentProcessorService_CreateProcessor_async - */ - createProcessor( - request?: protos.google.cloud.documentai.v1.ICreateProcessorRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.ICreateProcessorRequest|undefined, {}|undefined - ]>; - createProcessor( - request: protos.google.cloud.documentai.v1.ICreateProcessorRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.ICreateProcessorRequest|null|undefined, - {}|null|undefined>): void; - createProcessor( - request: protos.google.cloud.documentai.v1.ICreateProcessorRequest, - callback: Callback< - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.ICreateProcessorRequest|null|undefined, - {}|null|undefined>): void; - createProcessor( - request?: protos.google.cloud.documentai.v1.ICreateProcessorRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.ICreateProcessorRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.ICreateProcessorRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1.IProcessor, - protos.google.cloud.documentai.v1.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createProcessor(request, options, callback); - } - -/** - * 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 resource name of {@link google.cloud.documentai.v1.Processor|Processor} or - * {@link google.cloud.documentai.v1.ProcessorVersion|ProcessorVersion}. - * Format: `projects/{project}/locations/{location}/processors/{processor}`, - * or - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - * @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 include:samples/generated/v1/document_processor_service.batch_process_documents.js - * region_tag:documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async - */ - 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; - 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' - ] = this._gaxModule.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 include:samples/generated/v1/document_processor_service.batch_process_documents.js - * region_tag:documentai_v1_generated_DocumentProcessorService_BatchProcessDocuments_async - */ - async checkBatchProcessDocumentsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes the processor version, all artifacts under the processor version - * will be deleted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor version 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 include:samples/generated/v1/document_processor_service.delete_processor_version.js - * region_tag:documentai_v1_generated_DocumentProcessorService_DeleteProcessorVersion_async - */ - deleteProcessorVersion( - request?: protos.google.cloud.documentai.v1.IDeleteProcessorVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteProcessorVersion( - request: protos.google.cloud.documentai.v1.IDeleteProcessorVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProcessorVersion( - request: protos.google.cloud.documentai.v1.IDeleteProcessorVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProcessorVersion( - request?: protos.google.cloud.documentai.v1.IDeleteProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteProcessorVersion(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteProcessorVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.delete_processor_version.js - * region_tag:documentai_v1_generated_DocumentProcessorService_DeleteProcessorVersion_async - */ - async checkDeleteProcessorVersionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deploys the processor version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor version resource name to be deployed. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.deploy_processor_version.js - * region_tag:documentai_v1_generated_DocumentProcessorService_DeployProcessorVersion_async - */ - deployProcessorVersion( - request?: protos.google.cloud.documentai.v1.IDeployProcessorVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deployProcessorVersion( - request: protos.google.cloud.documentai.v1.IDeployProcessorVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deployProcessorVersion( - request: protos.google.cloud.documentai.v1.IDeployProcessorVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deployProcessorVersion( - request?: protos.google.cloud.documentai.v1.IDeployProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deployProcessorVersion(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deployProcessorVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.deploy_processor_version.js - * region_tag:documentai_v1_generated_DocumentProcessorService_DeployProcessorVersion_async - */ - async checkDeployProcessorVersionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deployProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Undeploys the processor version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor version resource name to be undeployed. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.undeploy_processor_version.js - * region_tag:documentai_v1_generated_DocumentProcessorService_UndeployProcessorVersion_async - */ - undeployProcessorVersion( - request?: protos.google.cloud.documentai.v1.IUndeployProcessorVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - undeployProcessorVersion( - request: protos.google.cloud.documentai.v1.IUndeployProcessorVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeployProcessorVersion( - request: protos.google.cloud.documentai.v1.IUndeployProcessorVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeployProcessorVersion( - request?: protos.google.cloud.documentai.v1.IUndeployProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.undeployProcessorVersion(request, options, callback); - } -/** - * Check the status of the long running operation returned by `undeployProcessorVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.undeploy_processor_version.js - * region_tag:documentai_v1_generated_DocumentProcessorService_UndeployProcessorVersion_async - */ - async checkUndeployProcessorVersionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.undeployProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * 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 include:samples/generated/v1/document_processor_service.delete_processor.js - * region_tag:documentai_v1_generated_DocumentProcessorService_DeleteProcessor_async - */ - deleteProcessor( - request?: protos.google.cloud.documentai.v1.IDeleteProcessorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteProcessor( - request: protos.google.cloud.documentai.v1.IDeleteProcessorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProcessor( - request: protos.google.cloud.documentai.v1.IDeleteProcessorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProcessor( - request?: protos.google.cloud.documentai.v1.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' - ] = this._gaxModule.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 include:samples/generated/v1/document_processor_service.delete_processor.js - * region_tag:documentai_v1_generated_DocumentProcessorService_DeleteProcessor_async - */ - async checkDeleteProcessorProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteProcessor, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * 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 include:samples/generated/v1/document_processor_service.enable_processor.js - * region_tag:documentai_v1_generated_DocumentProcessorService_EnableProcessor_async - */ - enableProcessor( - request?: protos.google.cloud.documentai.v1.IEnableProcessorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - enableProcessor( - request: protos.google.cloud.documentai.v1.IEnableProcessorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - enableProcessor( - request: protos.google.cloud.documentai.v1.IEnableProcessorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - enableProcessor( - request?: protos.google.cloud.documentai.v1.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' - ] = this._gaxModule.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 include:samples/generated/v1/document_processor_service.enable_processor.js - * region_tag:documentai_v1_generated_DocumentProcessorService_EnableProcessor_async - */ - async checkEnableProcessorProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.enableProcessor, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * 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 include:samples/generated/v1/document_processor_service.disable_processor.js - * region_tag:documentai_v1_generated_DocumentProcessorService_DisableProcessor_async - */ - disableProcessor( - request?: protos.google.cloud.documentai.v1.IDisableProcessorRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - disableProcessor( - request: protos.google.cloud.documentai.v1.IDisableProcessorRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - disableProcessor( - request: protos.google.cloud.documentai.v1.IDisableProcessorRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - disableProcessor( - request?: protos.google.cloud.documentai.v1.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' - ] = this._gaxModule.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 include:samples/generated/v1/document_processor_service.disable_processor.js - * region_tag:documentai_v1_generated_DocumentProcessorService_DisableProcessor_async - */ - async checkDisableProcessorProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.disableProcessor, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Set the default (active) version of a {@link google.cloud.documentai.v1.Processor|Processor} that will be used in - * {@link google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument|ProcessDocument} and - * {@link google.cloud.documentai.v1.DocumentProcessorService.BatchProcessDocuments|BatchProcessDocuments}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.processor - * Required. The resource name of the {@link google.cloud.documentai.v1.Processor|Processor} to change default version. - * @param {string} request.defaultProcessorVersion - * Required. The resource name of child {@link google.cloud.documentai.v1.ProcessorVersion|ProcessorVersion} to use as default. - * Format: - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.set_default_processor_version.js - * region_tag:documentai_v1_generated_DocumentProcessorService_SetDefaultProcessorVersion_async - */ - setDefaultProcessorVersion( - request?: protos.google.cloud.documentai.v1.ISetDefaultProcessorVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setDefaultProcessorVersion( - request: protos.google.cloud.documentai.v1.ISetDefaultProcessorVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setDefaultProcessorVersion( - request: protos.google.cloud.documentai.v1.ISetDefaultProcessorVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setDefaultProcessorVersion( - request?: protos.google.cloud.documentai.v1.ISetDefaultProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'processor': request.processor ?? '', - }); - this.initialize(); - return this.innerApiCalls.setDefaultProcessorVersion(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setDefaultProcessorVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.set_default_processor_version.js - * region_tag:documentai_v1_generated_DocumentProcessorService_SetDefaultProcessorVersion_async - */ - async checkSetDefaultProcessorVersionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.setDefaultProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * 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 {google.cloud.documentai.v1.DocumentSchema} request.documentSchema - * The document schema 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 include:samples/generated/v1/document_processor_service.review_document.js - * region_tag:documentai_v1_generated_DocumentProcessorService_ReviewDocument_async - */ - 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; - 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' - ] = this._gaxModule.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 include:samples/generated/v1/document_processor_service.review_document.js - * region_tag:documentai_v1_generated_DocumentProcessorService_ReviewDocument_async - */ - async checkReviewDocumentProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.reviewDocument, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the processor types that exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - * @param {number} request.pageSize - * The maximum number of processor types to return. - * If unspecified, at most 100 processor types will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - * @param {string} request.pageToken - * Used to retrieve the next page of results, empty if at the end of the list. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ProcessorType]{@link google.cloud.documentai.v1.ProcessorType}. - * 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 `listProcessorTypesAsync()` - * 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. - */ - listProcessorTypes( - request?: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1.IProcessorType[], - protos.google.cloud.documentai.v1.IListProcessorTypesRequest|null, - protos.google.cloud.documentai.v1.IListProcessorTypesResponse - ]>; - listProcessorTypes( - request: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorTypesRequest, - protos.google.cloud.documentai.v1.IListProcessorTypesResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessorType>): void; - listProcessorTypes( - request: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, - callback: PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorTypesRequest, - protos.google.cloud.documentai.v1.IListProcessorTypesResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessorType>): void; - listProcessorTypes( - request?: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorTypesRequest, - protos.google.cloud.documentai.v1.IListProcessorTypesResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessorType>, - callback?: PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorTypesRequest, - protos.google.cloud.documentai.v1.IListProcessorTypesResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessorType>): - Promise<[ - protos.google.cloud.documentai.v1.IProcessorType[], - protos.google.cloud.documentai.v1.IListProcessorTypesRequest|null, - protos.google.cloud.documentai.v1.IListProcessorTypesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProcessorTypes(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 location of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - * @param {number} request.pageSize - * The maximum number of processor types to return. - * If unspecified, at most 100 processor types will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - * @param {string} request.pageToken - * Used to retrieve the next page of results, empty if at the end of the list. - * @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 [ProcessorType]{@link google.cloud.documentai.v1.ProcessorType} 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 `listProcessorTypesAsync()` - * 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. - */ - listProcessorTypesStream( - request?: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessorTypes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessorTypes.createStream( - this.innerApiCalls.listProcessorTypes as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProcessorTypes`, 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 location of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - * @param {number} request.pageSize - * The maximum number of processor types to return. - * If unspecified, at most 100 processor types will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - * @param {string} request.pageToken - * Used to retrieve the next page of results, empty if at the end of the list. - * @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 - * [ProcessorType]{@link google.cloud.documentai.v1.ProcessorType}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.list_processor_types.js - * region_tag:documentai_v1_generated_DocumentProcessorService_ListProcessorTypes_async - */ - listProcessorTypesAsync( - request?: protos.google.cloud.documentai.v1.IListProcessorTypesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessorTypes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessorTypes.asyncIterate( - this.innerApiCalls['listProcessorTypes'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * 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.v1.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.v1.IListProcessorsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1.IProcessor[], - protos.google.cloud.documentai.v1.IListProcessorsRequest|null, - protos.google.cloud.documentai.v1.IListProcessorsResponse - ]>; - listProcessors( - request: protos.google.cloud.documentai.v1.IListProcessorsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorsRequest, - protos.google.cloud.documentai.v1.IListProcessorsResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessor>): void; - listProcessors( - request: protos.google.cloud.documentai.v1.IListProcessorsRequest, - callback: PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorsRequest, - protos.google.cloud.documentai.v1.IListProcessorsResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessor>): void; - listProcessors( - request?: protos.google.cloud.documentai.v1.IListProcessorsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorsRequest, - protos.google.cloud.documentai.v1.IListProcessorsResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessor>, - callback?: PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorsRequest, - protos.google.cloud.documentai.v1.IListProcessorsResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessor>): - Promise<[ - protos.google.cloud.documentai.v1.IProcessor[], - protos.google.cloud.documentai.v1.IListProcessorsRequest|null, - protos.google.cloud.documentai.v1.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' - ] = this._gaxModule.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.v1.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.v1.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessors']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessors.createStream( - this.innerApiCalls.listProcessors as 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.v1.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 include:samples/generated/v1/document_processor_service.list_processors.js - * region_tag:documentai_v1_generated_DocumentProcessorService_ListProcessors_async - */ - listProcessorsAsync( - request?: protos.google.cloud.documentai.v1.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessors']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessors.asyncIterate( - this.innerApiCalls['listProcessors'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists all versions of a processor. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project, location and processor) to list all versions. - * Format: `projects/{project}/locations/{location}/processors/{processor}` - * @param {number} request.pageSize - * The maximum number of processor versions to return. - * If unspecified, at most 10 processor versions will be returned. - * The maximum value is 20; values above 20 will be coerced to 20. - * @param {string} request.pageToken - * We will return the processor versions sorted by creation time. The page - * token will point to the next processor version. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ProcessorVersion]{@link google.cloud.documentai.v1.ProcessorVersion}. - * 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 `listProcessorVersionsAsync()` - * 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. - */ - listProcessorVersions( - request?: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1.IProcessorVersion[], - protos.google.cloud.documentai.v1.IListProcessorVersionsRequest|null, - protos.google.cloud.documentai.v1.IListProcessorVersionsResponse - ]>; - listProcessorVersions( - request: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, - protos.google.cloud.documentai.v1.IListProcessorVersionsResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessorVersion>): void; - listProcessorVersions( - request: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, - protos.google.cloud.documentai.v1.IListProcessorVersionsResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessorVersion>): void; - listProcessorVersions( - request?: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, - protos.google.cloud.documentai.v1.IListProcessorVersionsResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessorVersion>, - callback?: PaginationCallback< - protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, - protos.google.cloud.documentai.v1.IListProcessorVersionsResponse|null|undefined, - protos.google.cloud.documentai.v1.IProcessorVersion>): - Promise<[ - protos.google.cloud.documentai.v1.IProcessorVersion[], - protos.google.cloud.documentai.v1.IListProcessorVersionsRequest|null, - protos.google.cloud.documentai.v1.IListProcessorVersionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProcessorVersions(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, location and processor) to list all versions. - * Format: `projects/{project}/locations/{location}/processors/{processor}` - * @param {number} request.pageSize - * The maximum number of processor versions to return. - * If unspecified, at most 10 processor versions will be returned. - * The maximum value is 20; values above 20 will be coerced to 20. - * @param {string} request.pageToken - * We will return the processor versions sorted by creation time. The page - * token will point to the next processor version. - * @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 [ProcessorVersion]{@link google.cloud.documentai.v1.ProcessorVersion} 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 `listProcessorVersionsAsync()` - * 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. - */ - listProcessorVersionsStream( - request?: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessorVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessorVersions.createStream( - this.innerApiCalls.listProcessorVersions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProcessorVersions`, 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, location and processor) to list all versions. - * Format: `projects/{project}/locations/{location}/processors/{processor}` - * @param {number} request.pageSize - * The maximum number of processor versions to return. - * If unspecified, at most 10 processor versions will be returned. - * The maximum value is 20; values above 20 will be coerced to 20. - * @param {string} request.pageToken - * We will return the processor versions sorted by creation time. The page - * token will point to the next processor version. - * @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 - * [ProcessorVersion]{@link google.cloud.documentai.v1.ProcessorVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/document_processor_service.list_processor_versions.js - * region_tag:documentai_v1_generated_DocumentProcessorService_ListProcessorVersions_async - */ - listProcessorVersionsAsync( - request?: protos.google.cloud.documentai.v1.IListProcessorVersionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessorVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessorVersions.asyncIterate( - this.innerApiCalls['listProcessorVersions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * [google.longrunning.Operation]{@link - * external:"google.longrunning.Operation"}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * [google.longrunning.Operation]{@link - * external:"google.longrunning.Operation"}. The promise has a method named - * "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 processorVersion resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} processor - * @param {string} processor_version - * @returns {string} Resource name string. - */ - processorVersionPath(project:string,location:string,processor:string,processorVersion:string) { - return this.pathTemplates.processorVersionPathTemplate.render({ - project: project, - location: location, - processor: processor, - processor_version: processorVersion, - }); - } - - /** - * Parse the project from ProcessorVersion resource. - * - * @param {string} processorVersionName - * A fully-qualified path representing ProcessorVersion resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProcessorVersionName(processorVersionName: string) { - return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).project; - } - - /** - * Parse the location from ProcessorVersion resource. - * - * @param {string} processorVersionName - * A fully-qualified path representing ProcessorVersion resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProcessorVersionName(processorVersionName: string) { - return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).location; - } - - /** - * Parse the processor from ProcessorVersion resource. - * - * @param {string} processorVersionName - * A fully-qualified path representing ProcessorVersion resource. - * @returns {string} A string representing the processor. - */ - matchProcessorFromProcessorVersionName(processorVersionName: string) { - return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).processor; - } - - /** - * Parse the processor_version from ProcessorVersion resource. - * - * @param {string} processorVersionName - * A fully-qualified path representing ProcessorVersion resource. - * @returns {string} A string representing the processor_version. - */ - matchProcessorVersionFromProcessorVersionName(processorVersionName: string) { - return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).processor_version; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.documentProcessorServiceStub && !this._terminated) { - return this.documentProcessorServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client_config.json b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client_config.json deleted file mode 100644 index d5b952a9834..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_client_config.json +++ /dev/null @@ -1,97 +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" - }, - "FetchProcessorTypes": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProcessorTypes": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProcessors": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetProcessor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetProcessorVersion": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProcessorVersions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProcessorVersion": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeployProcessorVersion": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UndeployProcessorVersion": { - "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" - }, - "SetDefaultProcessorVersion": { - "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/google-cloud-documentai/v1/src/v1/document_processor_service_proto_list.json b/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_proto_list.json deleted file mode 100644 index a19f0a8b0ca..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/src/v1/document_processor_service_proto_list.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - "../../protos/google/cloud/documentai/v1/barcode.proto", - "../../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/document_schema.proto", - "../../protos/google/cloud/documentai/v1/geometry.proto", - "../../protos/google/cloud/documentai/v1/operation_metadata.proto", - "../../protos/google/cloud/documentai/v1/processor.proto", - "../../protos/google/cloud/documentai/v1/processor_type.proto" -] diff --git a/owl-bot-staging/google-cloud-documentai/v1/src/v1/gapic_metadata.json b/owl-bot-staging/google-cloud-documentai/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 0c0e9a859b2..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,205 +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" - ] - }, - "FetchProcessorTypes": { - "methods": [ - "fetchProcessorTypes" - ] - }, - "GetProcessor": { - "methods": [ - "getProcessor" - ] - }, - "GetProcessorVersion": { - "methods": [ - "getProcessorVersion" - ] - }, - "CreateProcessor": { - "methods": [ - "createProcessor" - ] - }, - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - }, - "DeleteProcessorVersion": { - "methods": [ - "deleteProcessorVersion" - ] - }, - "DeployProcessorVersion": { - "methods": [ - "deployProcessorVersion" - ] - }, - "UndeployProcessorVersion": { - "methods": [ - "undeployProcessorVersion" - ] - }, - "DeleteProcessor": { - "methods": [ - "deleteProcessor" - ] - }, - "EnableProcessor": { - "methods": [ - "enableProcessor" - ] - }, - "DisableProcessor": { - "methods": [ - "disableProcessor" - ] - }, - "SetDefaultProcessorVersion": { - "methods": [ - "setDefaultProcessorVersion" - ] - }, - "ReviewDocument": { - "methods": [ - "reviewDocument" - ] - }, - "ListProcessorTypes": { - "methods": [ - "listProcessorTypes", - "listProcessorTypesStream", - "listProcessorTypesAsync" - ] - }, - "ListProcessors": { - "methods": [ - "listProcessors", - "listProcessorsStream", - "listProcessorsAsync" - ] - }, - "ListProcessorVersions": { - "methods": [ - "listProcessorVersions", - "listProcessorVersionsStream", - "listProcessorVersionsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentProcessorServiceClient", - "rpcs": { - "ProcessDocument": { - "methods": [ - "processDocument" - ] - }, - "FetchProcessorTypes": { - "methods": [ - "fetchProcessorTypes" - ] - }, - "GetProcessor": { - "methods": [ - "getProcessor" - ] - }, - "GetProcessorVersion": { - "methods": [ - "getProcessorVersion" - ] - }, - "CreateProcessor": { - "methods": [ - "createProcessor" - ] - }, - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - }, - "DeleteProcessorVersion": { - "methods": [ - "deleteProcessorVersion" - ] - }, - "DeployProcessorVersion": { - "methods": [ - "deployProcessorVersion" - ] - }, - "UndeployProcessorVersion": { - "methods": [ - "undeployProcessorVersion" - ] - }, - "DeleteProcessor": { - "methods": [ - "deleteProcessor" - ] - }, - "EnableProcessor": { - "methods": [ - "enableProcessor" - ] - }, - "DisableProcessor": { - "methods": [ - "disableProcessor" - ] - }, - "SetDefaultProcessorVersion": { - "methods": [ - "setDefaultProcessorVersion" - ] - }, - "ReviewDocument": { - "methods": [ - "reviewDocument" - ] - }, - "ListProcessorTypes": { - "methods": [ - "listProcessorTypes", - "listProcessorTypesStream", - "listProcessorTypesAsync" - ] - }, - "ListProcessors": { - "methods": [ - "listProcessors", - "listProcessorsStream", - "listProcessorsAsync" - ] - }, - "ListProcessorVersions": { - "methods": [ - "listProcessorVersions", - "listProcessorVersionsStream", - "listProcessorVersionsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/src/v1/index.ts b/owl-bot-staging/google-cloud-documentai/v1/src/v1/index.ts deleted file mode 100644 index db3b76d115a..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {DocumentProcessorServiceClient} from './document_processor_service_client'; diff --git a/owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 27e40317e22..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const documentai = require('@google-cloud/documentai'); - -function main() { - const documentProcessorServiceClient = new documentai.DocumentProcessorServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index b1548f79d2e..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {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/google-cloud-documentai/v1/system-test/install.ts b/owl-bot-staging/google-cloud-documentai/v1/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-documentai/v1/test/gapic_document_processor_service_v1.ts b/owl-bot-staging/google-cloud-documentai/v1/test/gapic_document_processor_service_v1.ts deleted file mode 100644 index 67bce71db56..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/test/gapic_document_processor_service_v1.ts +++ /dev/null @@ -1,3558 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as documentprocessorserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.DocumentProcessorServiceClient', () => { - describe('Common methods', () => { - 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 for the initialized client', done => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.documentProcessorServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentProcessorServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.processDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes processDocument with closed client', 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ProcessRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.processDocument(request), expectedError); - }); - }); - - describe('fetchProcessorTypes', () => { - it('invokes fetchProcessorTypes 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.FetchProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.FetchProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1.FetchProcessorTypesResponse() - ); - client.innerApiCalls.fetchProcessorTypes = stubSimpleCall(expectedResponse); - const [response] = await client.fetchProcessorTypes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchProcessorTypes 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.FetchProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.FetchProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1.FetchProcessorTypesResponse() - ); - client.innerApiCalls.fetchProcessorTypes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.fetchProcessorTypes( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1.IFetchProcessorTypesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchProcessorTypes 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.FetchProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.FetchProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.fetchProcessorTypes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchProcessorTypes(request), expectedError); - const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchProcessorTypes with closed client', 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.FetchProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.FetchProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.fetchProcessorTypes(request), expectedError); - }); - }); - - describe('getProcessor', () => { - it('invokes getProcessor 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.GetProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1.Processor() - ); - client.innerApiCalls.getProcessor = stubSimpleCall(expectedResponse); - const [response] = await client.getProcessor(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessor 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.GetProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1.Processor() - ); - client.innerApiCalls.getProcessor = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProcessor( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessor|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessor 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.GetProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProcessor = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProcessor(request), expectedError); - const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessor with closed client', 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.GetProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProcessor(request), expectedError); - }); - }); - - describe('getProcessorVersion', () => { - it('invokes getProcessorVersion 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.GetProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1.ProcessorVersion() - ); - client.innerApiCalls.getProcessorVersion = stubSimpleCall(expectedResponse); - const [response] = await client.getProcessorVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessorVersion 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.GetProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1.ProcessorVersion() - ); - client.innerApiCalls.getProcessorVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProcessorVersion( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessorVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessorVersion 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.GetProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProcessorVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessorVersion with closed client', 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.GetProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.GetProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProcessorVersion(request), expectedError); - }); - }); - - describe('createProcessor', () => { - it('invokes createProcessor 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.CreateProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.CreateProcessorRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1.Processor() - ); - client.innerApiCalls.createProcessor = stubSimpleCall(expectedResponse); - const [response] = await client.createProcessor(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProcessor 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.CreateProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.CreateProcessorRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1.Processor() - ); - client.innerApiCalls.createProcessor = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProcessor( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessor|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProcessor 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.CreateProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.CreateProcessorRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProcessor = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProcessor(request), expectedError); - const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProcessor with closed client', 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.CreateProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.CreateProcessorRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProcessor(request), expectedError); - }); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.BatchProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.BatchProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.BatchProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchProcessDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.BatchProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchProcessDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('deleteProcessorVersion', () => { - it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteProcessorVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProcessorVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteProcessorVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteProcessorVersionProgress 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.checkDeleteProcessorVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteProcessorVersionProgress 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.checkDeleteProcessorVersionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deployProcessorVersion', () => { - it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.deployProcessorVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deployProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deployProcessorVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deployProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deployProcessorVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeployProcessorVersionProgress 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.checkDeployProcessorVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeployProcessorVersionProgress 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.checkDeployProcessorVersionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('undeployProcessorVersion', () => { - it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.UndeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.undeployProcessorVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.UndeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeployProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.undeployProcessorVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.UndeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.undeployProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.UndeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.undeployProcessorVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUndeployProcessorVersionProgress 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.checkUndeployProcessorVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUndeployProcessorVersionProgress 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.checkUndeployProcessorVersionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteProcessor', () => { - it('invokes deleteProcessor 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.DeleteProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProcessor 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.DeleteProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProcessor 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.DeleteProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteProcessor(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProcessor 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.DeleteProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DeleteProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteProcessor(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteProcessorProgress 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.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.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.checkDeleteProcessorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('enableProcessor', () => { - it('invokes enableProcessor 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.EnableProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.EnableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes enableProcessor 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.EnableProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.EnableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes enableProcessor 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.EnableProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.EnableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.enableProcessor(request), expectedError); - const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes enableProcessor 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.EnableProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.EnableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.enableProcessor(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkEnableProcessorProgress 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.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.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.checkEnableProcessorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('disableProcessor', () => { - it('invokes disableProcessor 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.DisableProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DisableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes disableProcessor 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.DisableProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DisableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes disableProcessor 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.DisableProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DisableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.disableProcessor(request), expectedError); - const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes disableProcessor 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.DisableProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.DisableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.disableProcessor(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDisableProcessorProgress 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.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.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.checkDisableProcessorProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('setDefaultProcessorVersion', () => { - it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.SetDefaultProcessorVersionRequest', ['processor']); - request.processor = defaultValue1; - const expectedHeaderRequestParams = `processor=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.setDefaultProcessorVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.SetDefaultProcessorVersionRequest', ['processor']); - request.processor = defaultValue1; - const expectedHeaderRequestParams = `processor=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setDefaultProcessorVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.SetDefaultProcessorVersionRequest', ['processor']); - request.processor = defaultValue1; - const expectedHeaderRequestParams = `processor=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setDefaultProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.SetDefaultProcessorVersionRequest', ['processor']); - request.processor = defaultValue1; - const expectedHeaderRequestParams = `processor=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setDefaultProcessorVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSetDefaultProcessorVersionProgress 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.checkSetDefaultProcessorVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetDefaultProcessorVersionProgress 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.checkSetDefaultProcessorVersionProgress(''), 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ReviewDocumentRequest', ['humanReviewConfig']); - request.humanReviewConfig = defaultValue1; - const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ReviewDocumentRequest', ['humanReviewConfig']); - request.humanReviewConfig = defaultValue1; - const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ReviewDocumentRequest', ['humanReviewConfig']); - request.humanReviewConfig = defaultValue1; - const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reviewDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ReviewDocumentRequest', ['humanReviewConfig']); - request.humanReviewConfig = defaultValue1; - const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reviewDocument(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('listProcessorTypes', () => { - it('invokes listProcessorTypes 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - ]; - client.innerApiCalls.listProcessorTypes = stubSimpleCall(expectedResponse); - const [response] = await client.listProcessorTypes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorTypes 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - ]; - client.innerApiCalls.listProcessorTypes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProcessorTypes( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessorType[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorTypes 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProcessorTypes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProcessorTypes(request), expectedError); - const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorTypesStream 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - ]; - client.descriptors.page.listProcessorTypes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProcessorTypesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1.ProcessorType[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1.ProcessorType) => { - 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.listProcessorTypes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProcessorTypes, request)); - assert( - (client.descriptors.page.listProcessorTypes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProcessorTypesStream 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProcessorTypes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProcessorTypesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1.ProcessorType[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1.ProcessorType) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProcessorTypes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProcessorTypes, request)); - assert( - (client.descriptors.page.listProcessorTypes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProcessorTypes 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorType()), - ]; - client.descriptors.page.listProcessorTypes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.documentai.v1.IProcessorType[] = []; - const iterable = client.listProcessorTypesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProcessorTypes 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProcessorTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProcessorTypesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.documentai.v1.IProcessorType[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProcessors', () => { - it('invokes listProcessors 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.ListProcessorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - ]; - client.innerApiCalls.listProcessors = stubSimpleCall(expectedResponse); - const [response] = await client.listProcessors(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessors 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.ListProcessorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - ]; - client.innerApiCalls.listProcessors = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProcessors( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessor[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessors 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.ListProcessorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProcessors = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProcessors(request), expectedError); - const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorsStream 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.ListProcessorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1.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.v1.Processor[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1.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( - (client.descriptors.page.listProcessors.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProcessorsStream 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.ListProcessorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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.v1.Processor[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1.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( - (client.descriptors.page.listProcessors.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProcessors 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.ListProcessorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - generateSampleMessage(new protos.google.cloud.documentai.v1.Processor()), - ]; - client.descriptors.page.listProcessors.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.documentai.v1.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( - (client.descriptors.page.listProcessors.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProcessors 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.ListProcessorsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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.v1.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( - (client.descriptors.page.listProcessors.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProcessorVersions', () => { - it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - ]; - client.innerApiCalls.listProcessorVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listProcessorVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - ]; - client.innerApiCalls.listProcessorVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProcessorVersions( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1.IProcessorVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProcessorVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProcessorVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorVersionsStream 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - ]; - client.descriptors.page.listProcessorVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProcessorVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1.ProcessorVersion[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1.ProcessorVersion) => { - 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.listProcessorVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProcessorVersions, request)); - assert( - (client.descriptors.page.listProcessorVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProcessorVersionsStream 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProcessorVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProcessorVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1.ProcessorVersion[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1.ProcessorVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProcessorVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProcessorVersions, request)); - assert( - (client.descriptors.page.listProcessorVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProcessorVersions 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1.ProcessorVersion()), - ]; - client.descriptors.page.listProcessorVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.documentai.v1.IProcessorVersion[] = []; - const iterable = client.listProcessorVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProcessorVersions 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProcessorVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProcessorVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.documentai.v1.IProcessorVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new documentprocessorserviceModule.v1.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.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)); - }); - }); - - describe('processorType', () => { - const fakePath = "/rendered/path/processorType"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - processor_type: "processorTypeValue", - }; - const client = new documentprocessorserviceModule.v1.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('processorVersion', () => { - const fakePath = "/rendered/path/processorVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - processor: "processorValue", - processor_version: "processorVersionValue", - }; - const client = new documentprocessorserviceModule.v1.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.processorVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.processorVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('processorVersionPath', () => { - const result = client.processorVersionPath("projectValue", "locationValue", "processorValue", "processorVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.processorVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProcessorVersionName', () => { - const result = client.matchProjectFromProcessorVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProcessorVersionName', () => { - const result = client.matchLocationFromProcessorVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorFromProcessorVersionName', () => { - const result = client.matchProcessorFromProcessorVersionName(fakePath); - assert.strictEqual(result, "processorValue"); - assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorVersionFromProcessorVersionName', () => { - const result = client.matchProcessorVersionFromProcessorVersionName(fakePath); - assert.strictEqual(result, "processorVersionValue"); - assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new documentprocessorserviceModule.v1.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/google-cloud-documentai/v1/tsconfig.json b/owl-bot-staging/google-cloud-documentai/v1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/google-cloud-documentai/v1/webpack.config.js b/owl-bot-staging/google-cloud-documentai/v1/webpack.config.js deleted file mode 100644 index fc7bef574e6..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/.eslintignore b/owl-bot-staging/google-cloud-documentai/v1beta1/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/.eslintrc.json b/owl-bot-staging/google-cloud-documentai/v1beta1/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/.gitignore b/owl-bot-staging/google-cloud-documentai/v1beta1/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/.jsdoc.js b/owl-bot-staging/google-cloud-documentai/v1beta1/.jsdoc.js deleted file mode 100644 index 75c76e52a54..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/documentai', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/.mocharc.js b/owl-bot-staging/google-cloud-documentai/v1beta1/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/.prettierrc.js b/owl-bot-staging/google-cloud-documentai/v1beta1/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/README.md b/owl-bot-staging/google-cloud-documentai/v1beta1/README.md deleted file mode 100644 index f41eef852ae..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/README.md +++ /dev/null @@ -1 +0,0 @@ -Documentai: Nodejs Client diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/linkinator.config.json b/owl-bot-staging/google-cloud-documentai/v1beta1/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/package.json b/owl-bot-staging/google-cloud-documentai/v1beta1/package.json deleted file mode 100644 index 6cf1bfd4fec..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/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/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto b/owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document.proto deleted file mode 100644 index aa95ecc2995..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/field_behavior.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; - - // Required. Entity type from a schema e.g. `Address`. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // 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/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto b/owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/document_understanding.proto deleted file mode 100644 index eb17286d4d5..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto b/owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto deleted file mode 100644 index 5772db74511..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/protos/google/cloud/documentai/v1beta1/geometry.proto +++ /dev/null @@ -1,57 +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; - - -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/google-cloud-documentai/v1beta1/samples/generated/v1beta1/document_understanding_service.batch_process_documents.js b/owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/document_understanding_service.batch_process_documents.js deleted file mode 100644 index 1c7c32af24f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/document_understanding_service.batch_process_documents.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(requests) { - // [START documentai_v1beta1_generated_DocumentUnderstandingService_BatchProcessDocuments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Individual requests for each document. - */ - // const requests = 1234 - /** - * 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. - */ - // const parent = 'abc123' - - // Imports the Documentai library - const {DocumentUnderstandingServiceClient} = require('@google-cloud/documentai').v1beta1; - - // Instantiates a client - const documentaiClient = new DocumentUnderstandingServiceClient(); - - async function callBatchProcessDocuments() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await documentaiClient.batchProcessDocuments(request); - const [response] = await operation.promise(); - console.log(response); - } - - callBatchProcessDocuments(); - // [END documentai_v1beta1_generated_DocumentUnderstandingService_BatchProcessDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.documentai.v1beta1.json b/owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.documentai.v1beta1.json deleted file mode 100644 index 134cb6b8536..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/samples/generated/v1beta1/snippet_metadata.google.cloud.documentai.v1beta1.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-documentai", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.documentai.v1beta1", - "version": "v1beta1" - } - ] - }, - "snippets": [ - { - "regionTag": "documentai_v1beta1_generated_DocumentUnderstandingService_BatchProcessDocuments_async", - "title": "DocumentUnderstandingService batchProcessDocuments Sample", - "origin": "API_DEFINITION", - "description": " LRO endpoint to batch process many documents.", - "canonical": true, - "file": "document_understanding_service.batch_process_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchProcessDocuments", - "fullName": "google.cloud.documentai.v1beta1.DocumentUnderstandingService.BatchProcessDocuments", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentUnderstandingServiceClient", - "fullName": "google.cloud.documentai.v1beta1.DocumentUnderstandingServiceClient" - }, - "method": { - "shortName": "BatchProcessDocuments", - "fullName": "google.cloud.documentai.v1beta1.DocumentUnderstandingService.BatchProcessDocuments", - "service": { - "shortName": "DocumentUnderstandingService", - "fullName": "google.cloud.documentai.v1beta1.DocumentUnderstandingService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/src/index.ts deleted file mode 100644 index 8036bee84c6..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as 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/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts deleted file mode 100644 index e330663b00b..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client.ts +++ /dev/null @@ -1,434 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, 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'; -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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new DocumentUnderstandingServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = []; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 -- - // ------------------- - -/** - * 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 include:samples/generated/v1beta1/document_understanding_service.batch_process_documents.js - * region_tag:documentai_v1beta1_generated_DocumentUnderstandingService_BatchProcessDocuments_async - */ - 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; - 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' - ] = this._gaxModule.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 include:samples/generated/v1beta1/document_understanding_service.batch_process_documents.js - * region_tag:documentai_v1beta1_generated_DocumentUnderstandingService_BatchProcessDocuments_async - */ - async checkBatchProcessDocumentsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, this._gaxModule.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 { - if (this.documentUnderstandingServiceStub && !this._terminated) { - return this.documentUnderstandingServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client_config.json b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_client_config.json deleted file mode 100644 index 2b4b0aff793..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_proto_list.json b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/document_understanding_service_proto_list.json deleted file mode 100644 index 684a577c02a..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/src/v1beta1/gapic_metadata.json b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/gapic_metadata.json deleted file mode 100644 index a283d1de127..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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": "@google-cloud/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/google-cloud-documentai/v1beta1/src/v1beta1/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/index.ts deleted file mode 100644 index c274d629b37..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/src/v1beta1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {DocumentUnderstandingServiceClient} from './document_understanding_service_client'; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 38e85714680..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const documentai = require('@google-cloud/documentai'); - -function main() { - const documentUnderstandingServiceClient = new documentai.DocumentUnderstandingServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index a4cb81abd01..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {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/google-cloud-documentai/v1beta1/system-test/install.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta1/test/gapic_document_understanding_service_v1beta1.ts b/owl-bot-staging/google-cloud-documentai/v1beta1/test/gapic_document_understanding_service_v1beta1.ts deleted file mode 100644 index 20d74d76637..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta1/test/gapic_document_understanding_service_v1beta1.ts +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as documentunderstandingserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function 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', () => { - describe('Common methods', () => { - 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 for the initialized client', done => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.documentUnderstandingServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new documentunderstandingserviceModule.v1beta1.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentUnderstandingServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchProcessDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta1.BatchProcessDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchProcessDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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/google-cloud-documentai/v1beta1/tsconfig.json b/owl-bot-staging/google-cloud-documentai/v1beta1/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta1/webpack.config.js b/owl-bot-staging/google-cloud-documentai/v1beta1/webpack.config.js deleted file mode 100644 index c6fdde56555..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/.eslintignore b/owl-bot-staging/google-cloud-documentai/v1beta2/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/.eslintrc.json b/owl-bot-staging/google-cloud-documentai/v1beta2/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/.gitignore b/owl-bot-staging/google-cloud-documentai/v1beta2/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/.jsdoc.js b/owl-bot-staging/google-cloud-documentai/v1beta2/.jsdoc.js deleted file mode 100644 index 75c76e52a54..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/documentai', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/.mocharc.js b/owl-bot-staging/google-cloud-documentai/v1beta2/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/.prettierrc.js b/owl-bot-staging/google-cloud-documentai/v1beta2/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/README.md b/owl-bot-staging/google-cloud-documentai/v1beta2/README.md deleted file mode 100644 index f41eef852ae..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/README.md +++ /dev/null @@ -1 +0,0 @@ -Documentai: Nodejs Client diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/linkinator.config.json b/owl-bot-staging/google-cloud-documentai/v1beta2/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/package.json b/owl-bot-staging/google-cloud-documentai/v1beta2/package.json deleted file mode 100644 index 6cf1bfd4fec..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto b/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto deleted file mode 100644 index a7255d7c1b9..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document.proto +++ /dev/null @@ -1,518 +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"; - -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; - - // Required. Entity type from a schema e.g. `Address`. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // 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]; - } - - // 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; - - // 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 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/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto b/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/document_understanding.proto deleted file mode 100644 index 137ba5e3116..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto b/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto deleted file mode 100644 index 8c97cb995cf..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/protos/google/cloud/documentai/v1beta2/geometry.proto +++ /dev/null @@ -1,56 +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; - - -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/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.batch_process_documents.js b/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.batch_process_documents.js deleted file mode 100644 index d8b7a19700e..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.batch_process_documents.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(requests) { - // [START documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Individual requests for each document. - */ - // const requests = 1234 - /** - * 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. - */ - // const parent = 'abc123' - - // Imports the Documentai library - const {DocumentUnderstandingServiceClient} = require('@google-cloud/documentai').v1beta2; - - // Instantiates a client - const documentaiClient = new DocumentUnderstandingServiceClient(); - - async function callBatchProcessDocuments() { - // Construct request - const request = { - requests, - }; - - // Run request - const [operation] = await documentaiClient.batchProcessDocuments(request); - const [response] = await operation.promise(); - console.log(response); - } - - callBatchProcessDocuments(); - // [END documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.process_document.js b/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.process_document.js deleted file mode 100644 index caf92fe342a..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/document_understanding_service.process_document.js +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(inputConfig) { - // [START documentai_v1beta2_generated_DocumentUnderstandingService_ProcessDocument_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * 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. - */ - // const parent = 'abc123' - /** - * Required. Information about the input file. - */ - // const inputConfig = {} - /** - * Optional. The desired output location. This field is only needed in - * BatchProcessDocumentsRequest. - */ - // const outputConfig = {} - /** - * 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. - */ - // const documentType = 'abc123' - /** - * Controls table extraction behavior. If not specified, the system will - * decide reasonable defaults. - */ - // const tableExtractionParams = {} - /** - * Controls form extraction behavior. If not specified, the system will - * decide reasonable defaults. - */ - // const formExtractionParams = {} - /** - * Controls entity extraction behavior. If not specified, the system will - * decide reasonable defaults. - */ - // const entityExtractionParams = {} - /** - * Controls OCR behavior. If not specified, the system will decide reasonable - * defaults. - */ - // const ocrParams = {} - /** - * Controls AutoML model prediction behavior. AutoMlParams cannot be used - * together with other Params. - */ - // const automlParams = {} - - // Imports the Documentai library - const {DocumentUnderstandingServiceClient} = require('@google-cloud/documentai').v1beta2; - - // Instantiates a client - const documentaiClient = new DocumentUnderstandingServiceClient(); - - async function callProcessDocument() { - // Construct request - const request = { - inputConfig, - }; - - // Run request - const response = await documentaiClient.processDocument(request); - console.log(response); - } - - callProcessDocument(); - // [END documentai_v1beta2_generated_DocumentUnderstandingService_ProcessDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.documentai.v1beta2.json b/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.documentai.v1beta2.json deleted file mode 100644 index a872a6a555f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/samples/generated/v1beta2/snippet_metadata.google.cloud.documentai.v1beta2.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-documentai", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.documentai.v1beta2", - "version": "v1beta2" - } - ] - }, - "snippets": [ - { - "regionTag": "documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async", - "title": "DocumentUnderstandingService batchProcessDocuments Sample", - "origin": "API_DEFINITION", - "description": " LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.", - "canonical": true, - "file": "document_understanding_service.batch_process_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchProcessDocuments", - "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.BatchProcessDocuments", - "async": true, - "parameters": [ - { - "name": "requests", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentUnderstandingServiceClient", - "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient" - }, - "method": { - "shortName": "BatchProcessDocuments", - "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.BatchProcessDocuments", - "service": { - "shortName": "DocumentUnderstandingService", - "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService" - } - } - } - }, - { - "regionTag": "documentai_v1beta2_generated_DocumentUnderstandingService_ProcessDocument_async", - "title": "DocumentUnderstandingService processDocument Sample", - "origin": "API_DEFINITION", - "description": " Processes a single document.", - "canonical": true, - "file": "document_understanding_service.process_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 96, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ProcessDocument", - "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.ProcessDocument", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "input_config", - "type": ".google.cloud.documentai.v1beta2.InputConfig" - }, - { - "name": "output_config", - "type": ".google.cloud.documentai.v1beta2.OutputConfig" - }, - { - "name": "document_type", - "type": "TYPE_STRING" - }, - { - "name": "table_extraction_params", - "type": ".google.cloud.documentai.v1beta2.TableExtractionParams" - }, - { - "name": "form_extraction_params", - "type": ".google.cloud.documentai.v1beta2.FormExtractionParams" - }, - { - "name": "entity_extraction_params", - "type": ".google.cloud.documentai.v1beta2.EntityExtractionParams" - }, - { - "name": "ocr_params", - "type": ".google.cloud.documentai.v1beta2.OcrParams" - }, - { - "name": "automl_params", - "type": ".google.cloud.documentai.v1beta2.AutoMlParams" - } - ], - "resultType": ".google.cloud.documentai.v1beta2.Document", - "client": { - "shortName": "DocumentUnderstandingServiceClient", - "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingServiceClient" - }, - "method": { - "shortName": "ProcessDocument", - "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService.ProcessDocument", - "service": { - "shortName": "DocumentUnderstandingService", - "fullName": "google.cloud.documentai.v1beta2.DocumentUnderstandingService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/src/index.ts deleted file mode 100644 index c40cad8fe68..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as 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/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts deleted file mode 100644 index 469642d50d4..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client.ts +++ /dev/null @@ -1,535 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, 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'; -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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new DocumentUnderstandingServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = []; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 -- - // ------------------- -/** - * 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 include:samples/generated/v1beta2/document_understanding_service.process_document.js - * region_tag:documentai_v1beta2_generated_DocumentUnderstandingService_ProcessDocument_async - */ - 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; - 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.processDocument(request, options, callback); - } - -/** - * 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 include:samples/generated/v1beta2/document_understanding_service.batch_process_documents.js - * region_tag:documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async - */ - 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; - 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' - ] = this._gaxModule.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 include:samples/generated/v1beta2/document_understanding_service.batch_process_documents.js - * region_tag:documentai_v1beta2_generated_DocumentUnderstandingService_BatchProcessDocuments_async - */ - async checkBatchProcessDocumentsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, this._gaxModule.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 { - if (this.documentUnderstandingServiceStub && !this._terminated) { - return this.documentUnderstandingServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client_config.json b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_client_config.json deleted file mode 100644 index 1dea85e9656..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_proto_list.json b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/document_understanding_service_proto_list.json deleted file mode 100644 index ee1f3779a2c..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/src/v1beta2/gapic_metadata.json b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/gapic_metadata.json deleted file mode 100644 index 49efed8a754..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/src/v1beta2/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/index.ts deleted file mode 100644 index c274d629b37..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/src/v1beta2/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {DocumentUnderstandingServiceClient} from './document_understanding_service_client'; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 38e85714680..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const documentai = require('@google-cloud/documentai'); - -function main() { - const documentUnderstandingServiceClient = new documentai.DocumentUnderstandingServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index a4cb81abd01..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {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/google-cloud-documentai/v1beta2/system-test/install.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta2/test/gapic_document_understanding_service_v1beta2.ts b/owl-bot-staging/google-cloud-documentai/v1beta2/test/gapic_document_understanding_service_v1beta2.ts deleted file mode 100644 index 3a849df02a0..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta2/test/gapic_document_understanding_service_v1beta2.ts +++ /dev/null @@ -1,428 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as documentunderstandingserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -describe('v1beta2.DocumentUnderstandingServiceClient', () => { - describe('Common methods', () => { - 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 for the initialized client', done => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.documentUnderstandingServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new documentunderstandingserviceModule.v1beta2.DocumentUnderstandingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentUnderstandingServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta2.ProcessDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta2.ProcessDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta2.ProcessDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.processDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes processDocument with closed client', 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta2.ProcessDocumentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.processDocument(request), expectedError); - }); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchProcessDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta2.BatchProcessDocumentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchProcessDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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/google-cloud-documentai/v1beta2/tsconfig.json b/owl-bot-staging/google-cloud-documentai/v1beta2/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta2/webpack.config.js b/owl-bot-staging/google-cloud-documentai/v1beta2/webpack.config.js deleted file mode 100644 index c6fdde56555..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta3/.eslintignore b/owl-bot-staging/google-cloud-documentai/v1beta3/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/.eslintrc.json b/owl-bot-staging/google-cloud-documentai/v1beta3/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/.gitignore b/owl-bot-staging/google-cloud-documentai/v1beta3/.gitignore deleted file mode 100644 index 5d32b23782f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta3/.jsdoc.js b/owl-bot-staging/google-cloud-documentai/v1beta3/.jsdoc.js deleted file mode 100644 index 75c76e52a54..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/documentai', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/.mocharc.js b/owl-bot-staging/google-cloud-documentai/v1beta3/.mocharc.js deleted file mode 100644 index 481c522b00f..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/.prettierrc.js b/owl-bot-staging/google-cloud-documentai/v1beta3/.prettierrc.js deleted file mode 100644 index 494e147865d..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/README.md b/owl-bot-staging/google-cloud-documentai/v1beta3/README.md deleted file mode 100644 index f41eef852ae..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/README.md +++ /dev/null @@ -1 +0,0 @@ -Documentai: Nodejs Client diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/linkinator.config.json b/owl-bot-staging/google-cloud-documentai/v1beta3/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/package.json b/owl-bot-staging/google-cloud-documentai/v1beta3/package.json deleted file mode 100644 index 41e8970a7ad..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.2" - }, - "devDependencies": { - "@types/mocha": "^9.1.1", - "@types/node": "^16.11.62", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^3.6.11", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.0.3", - "mocha": "^10.0.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^14.0.0", - "ts-loader": "^8.4.0", - "typescript": "^4.8.3", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/barcode.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/barcode.proto deleted file mode 100644 index 9b063faf287..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/barcode.proto +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -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 = "BarcodeProto"; -option java_package = "com.google.cloud.documentai.v1beta3"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; - -// Encodes the detailed information of a barcode. -message Barcode { - // Format of a barcode. - // The supported formats are: - // - // - `CODE_128`: Code 128 type. - // - `CODE_39`: Code 39 type. - // - `CODE_93`: Code 93 type. - // - `CODABAR`: Codabar type. - // - `DATA_MATRIX`: 2D Data Matrix type. - // - `ITF`: ITF type. - // - `EAN_13`: EAN-13 type. - // - `EAN_8`: EAN-8 type. - // - `QR_CODE`: 2D QR code type. - // - `UPC_A`: UPC-A type. - // - `UPC_E`: UPC-E type. - // - `PDF417`: PDF417 type. - // - `AZTEC`: 2D Aztec code type. - // - `DATABAR`: GS1 DataBar code type. - string format = 1; - - // Value format describes the format of the value that a barcode - // encodes. - // The supported formats are: - // - // - `CONTACT_INFO`: Contact information. - // - `EMAIL`: Email address. - // - `ISBN`: ISBN identifier. - // - `PHONE`: Phone number. - // - `PRODUCT`: Product. - // - `SMS`: SMS message. - // - `TEXT`: Text string. - // - `URL`: URL address. - // - `WIFI`: Wifi information. - // - `GEO`: Geo-localization. - // - `CALENDAR_EVENT`: Calendar event. - // - `DRIVER_LICENSE`: Driver's license. - string value_format = 2; - - // Raw value encoded in the barcode. - // For example: `'MEBKM:TITLE:Google;URL:https://www.google.com;;'`. - string raw_value = 3; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto deleted file mode 100644 index 2ae46db8e24..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document.proto +++ /dev/null @@ -1,820 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -import "google/api/field_behavior.proto"; -import "google/cloud/documentai/v1beta3/barcode.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"; - -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 AI. It is an -// interchange format that provides insights into documents and allows for -// collaboration between users and Document AI to iterate and optimize for -// quality. -message Document { - // For a large document, sharding may be performed to produce several - // document shards. Each document shard contains this field to detail which - // shard it is. - message ShardInfo { - // The 0-based index of this shard. - int64 shard_index = 1; - - // Total number of shards. - int64 shard_count = 2; - - // The index of the first character in [Document.text][google.cloud.documentai.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; - - // Font family such as `Arial`, `Times New Roman`. - // https://www.w3schools.com/cssref/pr_font_font-family.asp - string font_family = 8; - } - - // A page in a [Document][google.cloud.documentai.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 [deprecated = true]; - } - - // 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 [deprecated = true]; - } - - // A collection of tokens that a human would perceive as a line. - // Does not cross column boundaries, can be horizontal, vertical, etc. - message Line { - // [Layout][google.cloud.documentai.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 [deprecated = true]; - } - - // 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 [deprecated = true]; - } - - // A detected symbol. - message Symbol { - // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [Symbol][google.cloud.documentai.v1beta3.Document.Page.Symbol]. - Layout layout = 1; - - // A list of detected languages together with confidence. - repeated DetectedLanguage detected_languages = 2; - } - - // Detected non-text visual elements e.g. checkbox, signature etc. on the - // page. - message VisualElement { - // [Layout][google.cloud.documentai.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; - - // The history of this table. - Provenance provenance = 5; - } - - // 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; - - // Created for Labeling UI to export key text. - // If corrections were made to the text identified by the - // `field_name.text_anchor`, this field will contain the correction. - string corrected_key_text = 6; - - // Created for Labeling UI to export value text. - // If corrections were made to the text identified by the - // `field_value.text_anchor`, this field will contain the correction. - string corrected_value_text = 7; - - // The history of this annotation. - Provenance provenance = 8; - } - - // A detected barcode. - message DetectedBarcode { - // [Layout][google.cloud.documentai.v1beta3.Document.Page.Layout] for [DetectedBarcode][google.cloud.documentai.v1beta3.Document.Page.DetectedBarcode]. - Layout layout = 1; - - // Detailed barcode information of the [DetectedBarcode][google.cloud.documentai.v1beta3.Document.Page.DetectedBarcode]. - Barcode barcode = 2; - } - - // Detected language for a structural component. - message DetectedLanguage { - // The BCP-47 language code, such as `en-US` or `sr-Latn`. For more - // information, see - // https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 1; - - // Confidence of detected language. Range `[0, 1]`. - float confidence = 2; - } - - // Image Quality Scores for the page image - message ImageQualityScores { - // Image Quality Defects - message DetectedDefect { - // Name of the defect type. Supported values are: - // - // - `quality/defect_blurry` - // - `quality/defect_noisy` - // - `quality/defect_dark` - // - `quality/defect_faint` - // - `quality/defect_text_too_small` - // - `quality/defect_document_cutoff` - // - `quality/defect_text_cutoff` - // - `quality/defect_glare` - string type = 1; - - // Confidence of detected defect. Range `[0, 1]` where 1 indicates - // strong confidence of that the defect exists. - float confidence = 2; - } - - // The overall quality score. Range `[0, 1]` where 1 is perfect quality. - float quality_score = 1; - - // A list of detected defects. - repeated DetectedDefect detected_defects = 2; - } - - // 1-based index for current [Page][google.cloud.documentai.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; - - // A list of visually detected symbols on the page. - repeated Symbol symbols = 12; - - // A list of detected barcodes. - repeated DetectedBarcode detected_barcodes = 15; - - // Image Quality Scores. - ImageQualityScores image_quality_scores = 17; - - // The history of this page. - Provenance provenance = 16 [deprecated = true]; - } - - // An entity that could be a phrase in the text or a property that belongs to - // the document. It is a known entity type, such as a person, an organization, - // or location. - message Entity { - // Parsed and normalized entity value. - message NormalizedValue { - // An optional structured entity value. - // Must match entity type defined in schema if - // known. If this field is present, the `text` field could also be - // populated. - oneof structured_value { - // Money value. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/money.proto - google.type.Money money_value = 2; - - // Date value. Includes year, month, day. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/date.proto - google.type.Date date_value = 3; - - // DateTime value. Includes date, time, and timezone. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto - google.type.DateTime datetime_value = 4; - - // Postal address. See also: - // https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto - google.type.PostalAddress address_value = 5; - - // Boolean value. Can be used for entities with binary values, or for - // checkboxes. - bool boolean_value = 6; - - // Integer value. - int32 integer_value = 7; - - // Float value. - float float_value = 8; - } - - // Optional. An optional field to store a normalized string. - // For some entity types, one of respective `structured_value` fields may - // also be populated. Also not all the types of `structured_value` will be - // normalized. For example, some processors may not generate float - // or int normalized text by default. - // - // Below are sample formats mapped to structured values. - // - // - Money/Currency type (`money_value`) is in the ISO 4217 text format. - // - Date type (`date_value`) is in the ISO 8601 text format. - // - Datetime type (`datetime_value`) is in the ISO 8601 text format. - string text = 1 [(google.api.field_behavior) = OPTIONAL]; - } - - // Optional. Provenance of the entity. - // Text anchor indexing into the [Document.text][google.cloud.documentai.v1beta3.Document.text]. - TextAnchor text_anchor = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Required. Entity type from a schema e.g. `Address`. - string type = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`. - string mention_text = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Deprecated. Use `id` field instead. - string mention_id = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Confidence of detected Schema entity. Range `[0, 1]`. - float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Represents the provenance of this entity wrt. the location on the - // page where it was found. - PageAnchor page_anchor = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Canonical id. This will be a unique value in the entity list - // for this document. - string id = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Normalized entity value. Absent if the extracted value could not be - // converted or the type (e.g. address) is not supported for certain - // parsers. This field is also only populated for certain supported document - // types. - NormalizedValue normalized_value = 9 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Entities can be nested to form a hierarchical data structure representing - // the content in the document. - repeated Entity properties = 10 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The history of this annotation. - Provenance provenance = 11 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Whether the entity will be redacted for de-identification purposes. - bool redacted = 12 [(google.api.field_behavior) = OPTIONAL]; - } - - // Relationship between [Entities][google.cloud.documentai.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. It is always - // populated for formFields. - 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 { - // The parent element the current element is based on. Used for - // referencing/aligning, removal and replacement operations. - message Parent { - // The index of the index into current revision's parent_ids list. - int32 revision = 1; - - // The index of the parent item in the corresponding item list (eg. list - // of entities, properties within entities, etc.) in the parent revision. - int32 index = 3; - - // The id of the parent provenance. - int32 id = 2 [deprecated = true]; - } - - // If a processor or agent does an explicit operation on existing elements. - enum OperationType { - // Operation type unspecified. If no operation is specified a provenance - // entry is simply used to match against a `parent`. - OPERATION_TYPE_UNSPECIFIED = 0; - - // Add an element. - ADD = 1; - - // Remove an element identified by `parent`. - REMOVE = 2; - - // Replace an element identified by `parent`. - REPLACE = 3; - - // Request human review for the element identified by `parent`. - EVAL_REQUESTED = 4; - - // Element is reviewed and approved at human review, confidence will be - // set to 1.0. - EVAL_APPROVED = 5; - - // Element is skipped in the validation process. - EVAL_SKIPPED = 6; - } - - // The index of the revision that produced this element. - int32 revision = 1; - - // The Id of this operation. Needs to be unique within the scope of the - // revision. - int32 id = 2 [deprecated = true]; - - // References to the original elements that are replaced. - repeated Parent parents = 3; - - // The type of provenance operation. - OperationType type = 4; - } - - // Contains past or forward revisions of this document. - message Revision { - // Human Review information of the document. - message HumanReview { - // Human review state. e.g. `requested`, `succeeded`, `rejected`. - string state = 1; - - // A message providing more details about the current state of processing. - // For example, the rejection reason when the state is `rejected`. - string state_message = 2; - } - - // Who/what made the change - oneof source { - // If the change was made by a person specify the name or id of that - // person. - string agent = 4; - - // If the annotation was made by processor identify the processor by its - // resource name. - string processor = 5; - } - - // Id of the revision. Unique within the context of the document. - string id = 1; - - // The revisions that this revision is based on. This can include one or - // more parent (when documents are merged.) This field represents the - // index into the `revisions` field. - repeated int32 parent = 2 [deprecated = true]; - - // The revisions that this revision is based on. Must include all the ids - // that have anything to do with this revision - eg. there are - // `provenance.parent.revision` fields that index into this field. - repeated string parent_ids = 7; - - // The time that the revision was created. - google.protobuf.Timestamp create_time = 3; - - // Human Review information of this revision. - HumanReview human_review = 6; - } - - // This message is used for text changes aka. OCR corrections. - message TextChange { - // Provenance of the correction. - // Text anchor indexing into the [Document.text][google.cloud.documentai.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 [deprecated = true]; - } - - // Original source document from the user. - oneof source { - // Optional. Currently supports Google Cloud Storage URI of the form - // `gs://bucket_name/object_name`. Object versioning is not supported. - // See [Google Cloud Storage Request - // URIs](https://cloud.google.com/storage/docs/reference-uris) for more - // info. - string uri = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Inline document content, represented as a stream of bytes. - // Note: As with all `bytes` fields, protobuffers use a pure binary - // representation, whereas JSON representations use base64. - bytes content = 2 [(google.api.field_behavior) = OPTIONAL]; - } - - // An IANA published MIME type (also referred to as media type). For more - // information, see - // https://www.iana.org/assignments/media-types/media-types.xhtml. - string mime_type = 3; - - // Optional. UTF-8 encoded text in reading order from the document. - string text = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Placeholder. Styles for the [Document.text][google.cloud.documentai.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; - - // Placeholder. Relationship among [Document.entities][google.cloud.documentai.v1beta3.Document.entities]. - repeated EntityRelation entity_relations = 8; - - // Placeholder. A list of text corrections made to [Document.text][google.cloud.documentai.v1beta3.Document.text]. This - // is usually used for annotating corrections to OCR mistakes. Text changes - // for a given revision may not overlap with each other. - repeated TextChange text_changes = 14; - - // Information about the sharding if this document is sharded part of a larger - // document. If the document is not sharded, this message is not specified. - ShardInfo shard_info = 9; - - // Any error that occurred while processing this document. - google.rpc.Status error = 10; - - // Placeholder. Revision history of this document. - repeated Revision revisions = 13; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto deleted file mode 100644 index e41458e0a24..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_io.proto +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -import "google/protobuf/field_mask.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][google.cloud.documentai.v1beta3.RawDocument.content]. - string mime_type = 2; -} - -// Specifies a document stored on Cloud Storage. -message GcsDocument { - // The Cloud Storage object uri. - string gcs_uri = 1; - - // An IANA MIME type (RFC6838) of the content. - string mime_type = 2; -} - -// Specifies a set of documents on Cloud Storage. -message GcsDocuments { - // The list of documents. - repeated GcsDocument documents = 1; -} - -// Specifies all documents on Cloud Storage with a common prefix. -message GcsPrefix { - // The URI prefix. - string gcs_uri_prefix = 1; -} - -// The common config to specify a set of documents used as input. -message BatchDocumentsInputConfig { - // The source. - oneof source { - // The set of documents that match the specified Cloud Storage `gcs_prefix`. - GcsPrefix gcs_prefix = 1; - - // The set of documents individually specified on Cloud Storage. - GcsDocuments gcs_documents = 2; - } -} - -// Config that controls the output of documents. All documents will be written -// as a JSON file. -message DocumentOutputConfig { - // The configuration used when outputting documents. - message GcsOutputConfig { - // The Cloud Storage uri (a directory) of the output. - string gcs_uri = 1; - - // Specifies which fields to include in the output documents. - // Only supports top level document and pages field so it must be in the - // form of `{document_field_name}` or `pages.{page_field_name}`. - google.protobuf.FieldMask field_mask = 2; - } - - // The destination of the results. - oneof destination { - // Output config to write the results to Cloud Storage. - GcsOutputConfig gcs_output_config = 1; - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto deleted file mode 100644 index 34e3380413b..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_processor_service.proto +++ /dev/null @@ -1,1070 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.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/document_schema.proto"; -import "google/cloud/documentai/v1beta3/evaluation.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"; -option (google.api.resource_definition) = { - type: "documentai.googleapis.com/HumanReviewConfig" - pattern: "projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig" -}; -option (google.api.resource_definition) = { - type: "documentai.googleapis.com/Location" - pattern: "projects/{project}/locations/{location}" -}; - -// Service to call Cloud DocumentAI to process documents according to the -// processor's definition. Processors are built using state-of-the-art Google -// AI such as natural language, computer vision, and translation to extract -// structured information from unstructured or semi-structured documents. -service DocumentProcessorService { - option (google.api.default_host) = "documentai.googleapis.com"; - option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - - // Processes a single document. - rpc ProcessDocument(ProcessRequest) returns (ProcessResponse) { - option (google.api.http) = { - post: "/v1beta3/{name=projects/*/locations/*/processors/*}:process" - body: "*" - additional_bindings { - post: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}:process" - body: "*" - } - }; - option (google.api.method_signature) = "name"; - } - - // LRO endpoint to batch process many documents. The output is written - // to Cloud Storage as JSON in the [Document] format. - rpc BatchProcessDocuments(BatchProcessRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta3/{name=projects/*/locations/*/processors/*}:batchProcess" - body: "*" - additional_bindings { - post: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}:batchProcess" - body: "*" - } - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "BatchProcessResponse" - metadata_type: "BatchProcessMetadata" - }; - } - - // Fetches processor types. Note that we do not use ListProcessorTypes here - // because it is not paginated. - rpc FetchProcessorTypes(FetchProcessorTypesRequest) returns (FetchProcessorTypesResponse) { - option (google.api.http) = { - get: "/v1beta3/{parent=projects/*/locations/*}:fetchProcessorTypes" - }; - option (google.api.method_signature) = "parent"; - } - - // Lists the processor types that exist. - rpc ListProcessorTypes(ListProcessorTypesRequest) returns (ListProcessorTypesResponse) { - option (google.api.http) = { - get: "/v1beta3/{parent=projects/*/locations/*}/processorTypes" - }; - option (google.api.method_signature) = "parent"; - } - - // Lists all processors which belong to this project. - rpc ListProcessors(ListProcessorsRequest) returns (ListProcessorsResponse) { - option (google.api.http) = { - get: "/v1beta3/{parent=projects/*/locations/*}/processors" - }; - option (google.api.method_signature) = "parent"; - } - - // Gets a processor detail. - rpc GetProcessor(GetProcessorRequest) returns (Processor) { - option (google.api.http) = { - get: "/v1beta3/{name=projects/*/locations/*/processors/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Trains a new processor version. - // Operation metadata is returned as - // cloud_documentai_core.TrainProcessorVersionMetadata. - rpc TrainProcessorVersion(TrainProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta3/{parent=projects/*/locations/*/processors/*}/processorVersions:train" - body: "*" - }; - option (google.api.method_signature) = "parent,processor_version"; - option (google.longrunning.operation_info) = { - response_type: "TrainProcessorVersionResponse" - metadata_type: "TrainProcessorVersionMetadata" - }; - } - - // Gets a processor version detail. - rpc GetProcessorVersion(GetProcessorVersionRequest) returns (ProcessorVersion) { - option (google.api.http) = { - get: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all versions of a processor. - rpc ListProcessorVersions(ListProcessorVersionsRequest) returns (ListProcessorVersionsResponse) { - option (google.api.http) = { - get: "/v1beta3/{parent=projects/*/locations/*/processors/*}/processorVersions" - }; - option (google.api.method_signature) = "parent"; - } - - // Deletes the processor version, all artifacts under the processor version - // will be deleted. - rpc DeleteProcessorVersion(DeleteProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "DeleteProcessorVersionMetadata" - }; - } - - // Deploys the processor version. - rpc DeployProcessorVersion(DeployProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}:deploy" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "DeployProcessorVersionResponse" - metadata_type: "DeployProcessorVersionMetadata" - }; - } - - // Undeploys the processor version. - rpc UndeployProcessorVersion(UndeployProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*}:undeploy" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "UndeployProcessorVersionResponse" - metadata_type: "UndeployProcessorVersionMetadata" - }; - } - - // Creates a processor from the type processor that the user chose. - // The processor will be at "ENABLED" state by default after its creation. - rpc CreateProcessor(CreateProcessorRequest) returns (Processor) { - option (google.api.http) = { - post: "/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" - }; - } - - // Set the default (active) version of a [Processor][google.cloud.documentai.v1beta3.Processor] that will be used in - // [ProcessDocument][google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument] and - // [BatchProcessDocuments][google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments]. - rpc SetDefaultProcessorVersion(SetDefaultProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta3/{processor=projects/*/locations/*/processors/*}:setDefaultProcessorVersion" - body: "*" - }; - option (google.longrunning.operation_info) = { - response_type: "SetDefaultProcessorVersionResponse" - metadata_type: "SetDefaultProcessorVersionMetadata" - }; - } - - // Send a document for Human Review. The input document should be processed by - // the specified processor. - rpc ReviewDocument(ReviewDocumentRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/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" - }; - } - - // Evaluates a ProcessorVersion against annotated documents, producing an - // Evaluation. - rpc EvaluateProcessorVersion(EvaluateProcessorVersionRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1beta3/{processor_version=projects/*/locations/*/processors/*/processorVersions/*}:evaluateProcessorVersion" - body: "*" - }; - option (google.api.method_signature) = "processor_version"; - option (google.longrunning.operation_info) = { - response_type: "EvaluateProcessorVersionResponse" - metadata_type: "EvaluateProcessorVersionMetadata" - }; - } - - // Retrieves a specific evaluation. - rpc GetEvaluation(GetEvaluationRequest) returns (Evaluation) { - option (google.api.http) = { - get: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*/evaluations/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Retrieves a set of evaluations for a given processor version. - rpc ListEvaluations(ListEvaluationsRequest) returns (ListEvaluationsResponse) { - option (google.api.http) = { - get: "/v1beta3/{parent=projects/*/locations/*/processors/*/processorVersions/*}/evaluations" - }; - option (google.api.method_signature) = "parent"; - } -} - -// Request message for the process document method. -message ProcessRequest { - // The document payload. - oneof source { - // An inline document proto. - Document inline_document = 4; - - // A raw document content (bytes). - RawDocument raw_document = 5; - } - - // Required. The resource name of the [Processor][google.cloud.documentai.v1beta3.Processor] or - // [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion] - // to use for processing. If a [Processor][google.cloud.documentai.v1beta3.Processor] is specified, the server will use - // its [default version][google.cloud.documentai.v1beta3.Processor.default_processor_version]. Format: - // `projects/{project}/locations/{location}/processors/{processor}`, or - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "*" - } - ]; - - // 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; - - // Specifies which fields to include in ProcessResponse's document. - // Only supports top level document and pages field so it must be in the form - // of `{document_field_name}` or `pages.{page_field_name}`. - google.protobuf.FieldMask field_mask = 6; -} - -// The status of human review on a processed document. -message HumanReviewStatus { - // The final state of human review on a processed document. - enum State { - // Human review state is unspecified. Most likely due to an internal error. - STATE_UNSPECIFIED = 0; - - // Human review is skipped for the document. This can happen because human - // review is not enabled on the processor or the processing request has - // been set to skip this document. - SKIPPED = 1; - - // Human review validation is triggered and passed, so no review is needed. - VALIDATION_PASSED = 2; - - // Human review validation is triggered and the document is under review. - IN_PROGRESS = 3; - - // Some error happened during triggering human review, see the - // [state_message] for details. - ERROR = 4; - } - - // The state of human review on the processing request. - State state = 1; - - // A message providing more details about the human review state. - string state_message = 2; - - // The name of the operation triggered by the processed document. This field - // is populated only when the [state] is [HUMAN_REVIEW_IN_PROGRESS]. It has - // the same response type and metadata as the long running operation returned - // by [ReviewDocument] method. - string human_review_operation = 3; -} - -// Response message for the process document method. -message ProcessResponse { - // The document payload, will populate fields based on the processor's - // behavior. - Document document = 1; - - // The 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 resource name of [Processor][google.cloud.documentai.v1beta3.Processor] or - // [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion]. - // Format: `projects/{project}/locations/{location}/processors/{processor}`, - // or - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "*" - } - ]; - - // The input 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 processing the document. - google.rpc.Status status = 2; - - // The output_gcs_destination (in the request as `output_gcs_destination`) - // of the processed document if it was successful, otherwise empty. - string output_gcs_destination = 3; - - // The 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. - // The available processor types may depend on the allow-listing on projects. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/ProcessorType" - } - ]; -} - -// Response message for fetch processor types. -message FetchProcessorTypesResponse { - // The list of processor types. - repeated ProcessorType processor_types = 1; -} - -// Request message for list processor types. -message ListProcessorTypesRequest { - // Required. The location of processor type to list. - // The available processor types may depend on the allow-listing on projects. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/ProcessorType" - } - ]; - - // The maximum number of processor types to return. - // If unspecified, at most 100 processor types will be returned. - // The maximum value is 500; values above 500 will be coerced to 500. - int32 page_size = 2; - - // Used to retrieve the next page of results, empty if at the end of the list. - string page_token = 3; -} - -// Response message for list processor types. -message ListProcessorTypesResponse { - // The processor types. - repeated ProcessorType processor_types = 1; - - // Points to the next page, otherwise empty. - string next_page_token = 2; -} - -// Request message for list all processors belongs to a project. -message ListProcessorsRequest { - // Required. The parent (project and location) which owns this collection of Processors. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/Processor" - } - ]; - - // The maximum number of processors to return. - // If unspecified, at most 50 processors will be returned. - // The maximum value is 100; values above 100 will be coerced to 100. - int32 page_size = 2; - - // We will return the processors sorted by creation time. The page token - // will point to the next processor. - string page_token = 3; -} - -// Response message for list processors. -message ListProcessorsResponse { - // The list of processors. - repeated Processor processors = 1; - - // Points to the next processor, otherwise empty. - string next_page_token = 2; -} - -// Request message for get processor. -message GetProcessorRequest { - // Required. The processor resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// Request message for get processor version. -message GetProcessorVersionRequest { - // Required. The processor resource name. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Request message for list all processor versions belongs to a processor. -message ListProcessorVersionsRequest { - // Required. The parent (project, location and processor) to list all versions. - // Format: `projects/{project}/locations/{location}/processors/{processor}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/ProcessorVersion" - } - ]; - - // The maximum number of processor versions to return. - // If unspecified, at most 10 processor versions will be returned. - // The maximum value is 20; values above 20 will be coerced to 20. - int32 page_size = 2; - - // We will return the processor versions sorted by creation time. The page - // token will point to the next processor version. - string page_token = 3; -} - -// Response message for list processors. -message ListProcessorVersionsResponse { - // The list of processors. - repeated ProcessorVersion processor_versions = 1; - - // Points to the next processor, otherwise empty. - string next_page_token = 2; -} - -// Request message for the delete processor version method. -message DeleteProcessorVersionRequest { - // Required. The processor version resource name to be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// The long running operation metadata for delete processor version method. -message DeleteProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for the deploy processor version method. -message DeployProcessorVersionRequest { - // Required. The processor version resource name to be deployed. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Response message for the deploy processor version method. -message DeployProcessorVersionResponse { - -} - -// The long running operation metadata for deploy processor version method. -message DeployProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for the undeploy processor version method. -message UndeployProcessorVersionRequest { - // Required. The processor version resource name to be undeployed. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Response message for the undeploy processor version method. -message UndeployProcessorVersionResponse { - -} - -// The long running operation metadata for the undeploy processor version -// method. -message UndeployProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for create a processor. Notice this request is sent to -// a regionalized backend service, and if the processor type is not available -// on that region, the creation will fail. -message CreateProcessorRequest { - // Required. The parent (project and location) under which to create the processor. - // Format: `projects/{project}/locations/{location}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/Processor" - } - ]; - - // Required. The processor to be created, requires [processor_type] and [display_name] - // to be set. Also, the processor is under CMEK if CMEK fields are set. - Processor processor = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request message for the delete processor method. -message DeleteProcessorRequest { - // Required. The processor resource name to be deleted. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// The long running operation metadata for delete processor method. -message DeleteProcessorMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} - -// Request message for the enable processor method. -message EnableProcessorRequest { - // Required. The processor resource name to be enabled. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// Response message for the enable processor method. -// Intentionally empty proto for adding fields in future. -message EnableProcessorResponse { - -} - -// The long running operation metadata for enable processor method. -message EnableProcessorMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} - -// Request message for the disable processor method. -message DisableProcessorRequest { - // Required. The processor resource name to be disabled. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; -} - -// Response message for the disable processor method. -// Intentionally empty proto for adding fields in future. -message DisableProcessorResponse { - -} - -// The long running operation metadata for disable processor method. -message DisableProcessorMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 5; -} - -// Request message for the set default processor version method. -message SetDefaultProcessorVersionRequest { - // Required. The resource name of the [Processor][google.cloud.documentai.v1beta3.Processor] to change default version. - string processor = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Processor" - } - ]; - - // Required. The resource name of child [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion] to use as default. - // Format: - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` - string default_processor_version = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; -} - -// Response message for set default processor version method. -message SetDefaultProcessorVersionResponse { - -} - -// The long running operation metadata for set default processor version -// method. -message SetDefaultProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Request message for the create processor version method. -message TrainProcessorVersionRequest { - // The input data used to train a new `ProcessorVersion`. - message InputData { - // The documents used for training the new version. - BatchDocumentsInputConfig training_documents = 3; - - // The documents used for testing the trained version. - BatchDocumentsInputConfig test_documents = 4; - } - - // Required. The parent (project, location and processor) to create the new version for. - // Format: `projects/{project}/locations/{location}/processors/{processor}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "documentai.googleapis.com/ProcessorVersion" - } - ]; - - // Required. The processor version to be created. - ProcessorVersion processor_version = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The schema the processor version will be trained with. - DocumentSchema document_schema = 10 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The input data used to train the `ProcessorVersion`. - InputData input_data = 4 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The processor version to use as a base for training. This processor version - // must be a child of `parent`. Format: - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`. - string base_processor_version = 8 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response for the TrainProcessorVersion method. -message TrainProcessorVersionResponse { - // The resource name of the processor version produced by training. - string processor_version = 1; -} - -// The metadata that represents a processor version being created. -message TrainProcessorVersionMetadata { - // The dataset validation information. - // This includes any and all errors with documents and the dataset. - message DatasetValidation { - // The total number of document errors. - int32 document_error_count = 3; - - // The total number of dataset errors. - int32 dataset_error_count = 4; - - // Error information pertaining to specific documents. A maximum of 10 - // document errors will be returned. - // Any document with errors will not be used throughout training. - repeated google.rpc.Status document_errors = 1; - - // Error information for the dataset as a whole. A maximum of 10 dataset - // errors will be returned. - // A single dataset error is terminal for training. - repeated google.rpc.Status dataset_errors = 2; - } - - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; - - // The training dataset validation information. - DatasetValidation training_dataset_validation = 2; - - // The test dataset validation information. - DatasetValidation test_dataset_validation = 3; -} - -// Request message for review document method. -message ReviewDocumentRequest { - // The priority level of the human review task. - enum Priority { - // The default priority level. - DEFAULT = 0; - - // The urgent priority level. The labeling manager should allocate labeler - // resource to the urgent task queue to respect this priority level. - URGENT = 1; - } - - // The document payload. - oneof source { - // An inline document proto. - Document inline_document = 4; - } - - // Required. The resource name of the HumanReviewConfig that the document will be - // reviewed with. - string human_review_config = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/HumanReviewConfig" - } - ]; - - // 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; - - // The document schema of the human review task. - DocumentSchema document_schema = 6; -} - -// Response message for review document method. -message ReviewDocumentResponse { - // Possible states of the review operation. - enum State { - // The default value. This value is used if the state is omitted. - STATE_UNSPECIFIED = 0; - - // The review operation is rejected by the reviewer. - REJECTED = 1; - - // The review operation is succeeded. - SUCCEEDED = 2; - } - - // The Cloud Storage uri for the human reviewed document if the review is - // succeeded. - string gcs_destination = 1; - - // The state of the review operation. - State state = 2; - - // The reason why the review is rejected by reviewer. - string rejection_reason = 3; -} - -// The long running operation metadata for review document method. -message ReviewDocumentOperationMetadata { - // 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; - - // The Crowd Compute question ID. - string question_id = 6; -} - -// Evaluates the given ProcessorVersion against the supplied documents. -message EvaluateProcessorVersionRequest { - // Required. The resource name of the [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion] to evaluate. - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - string processor_version = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; - - // Optional. The documents used in the evaluation. If unspecified, use the processor's - // dataset as evaluation input. - BatchDocumentsInputConfig evaluation_documents = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Metadata of the EvaluateProcessorVersion method. -message EvaluateProcessorVersionMetadata { - // The basic metadata of the long running operation. - CommonOperationMetadata common_metadata = 1; -} - -// Metadata of the EvaluateProcessorVersion method. -message EvaluateProcessorVersionResponse { - // The resource name of the created evaluation. - string evaluation = 2; -} - -// Retrieves a specific Evaluation. -message GetEvaluationRequest { - // Required. The resource name of the [Evaluation][google.cloud.documentai.v1beta3.Evaluation] to get. - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/Evaluation" - } - ]; -} - -// Retrieves a list of evaluations for a given ProcessorVersion. -message ListEvaluationsRequest { - // Required. The resource name of the [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion] to list evaluations for. - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - } - ]; - - // The standard list page size. - // If unspecified, at most 5 evaluations will be returned. - // The maximum value is 100; values above 100 will be coerced to 100. - int32 page_size = 2; - - // A page token, received from a previous `ListEvaluations` call. - // Provide this to retrieve the subsequent page. - string page_token = 3; -} - -// The response from ListEvaluations. -message ListEvaluationsResponse { - // The evaluations requested. - repeated Evaluation evaluations = 1; - - // A token, which can be sent as `page_token` to retrieve the next page. - // If this field is omitted, there are no subsequent pages. - string next_page_token = 2; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_schema.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_schema.proto deleted file mode 100644 index 1e29f7c89d9..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/document_schema.proto +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -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 = "DocumentAiDocumentSchema"; -option java_package = "com.google.cloud.documentai.v1beta3"; -option php_namespace = "Google\\Cloud\\DocumentAI\\V1beta3"; -option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; - -// The schema defines the output of the processed document by a processor. -message DocumentSchema { - // EntityType is the wrapper of a label of the corresponding model with - // detailed attributes and limitations for entity-based processors. Multiple - // types can also compose a dependency tree to represent nested types. - message EntityType { - // Defines the a list of enum values. - message EnumValues { - // The individual values that this enum values type can include. - repeated string values = 1; - } - - // Defines properties that can be part of the entity type. - message Property { - // Types of occurrences of the entity type in the document. Note: this - // represents the number of instances of an entity types, not number of - // mentions of a given entity instance. - enum OccurrenceType { - // Unspecified occurrence type. - OCCURRENCE_TYPE_UNSPECIFIED = 0; - - // There will be zero or one instance of this entity type. - OPTIONAL_ONCE = 1; - - // The entity type will appear zero or multiple times. - OPTIONAL_MULTIPLE = 2; - - // The entity type will only appear exactly once. - REQUIRED_ONCE = 3; - - // The entity type will appear once or more times. - REQUIRED_MULTIPLE = 4; - } - - // The name of the property. Follows the same guidelines as the - // EntityType name. - string name = 1; - - // A reference to the value type of the property. This type is subject - // to the same conventions as the `Entity.base_types` field. - string value_type = 2; - - // Occurrence type limits the number of instances an entity type appears - // in the document. - OccurrenceType occurrence_type = 3; - } - - oneof value_source { - // If specified, lists all the possible values for this entity. This - // should not be more than a handful of values. If the number of values - // is >10 or could change frequently use the `EntityType.value_ontology` - // field and specify a list of all possible values in a value ontology - // file. - EnumValues enum_values = 14; - } - - // User defined name for the type. - string display_name = 13; - - // Name of the type. It must be unique within the schema file and - // cannot be a 'Common Type'. Besides that we use the following naming - // conventions: - // - // - *use `snake_casing`* - // - name matching is case-insensitive - // - Maximum 64 characters. - // - Must start with a letter. - // - Allowed characters: ASCII letters `[a-z0-9_-]`. (For backward - // compatibility internal infrastructure and tooling can handle any ascii - // character) - // - The `/` is sometimes used to denote a property of a type. For example - // `line_item/amount`. This convention is deprecated, but will still be - // honored for backward compatibility. - string name = 1; - - // The entity type that this type is derived from. For now, one and only - // one should be set. - repeated string base_types = 2; - - // Describing the nested structure, or composition of an entity. - repeated Property properties = 6; - } - - // Metadata for global schema behavior. - message Metadata { - // If true, a `document` entity type can be applied to subdocument ( - // splitting). Otherwise, it can only be applied to the entire document - // (classification). - bool document_splitter = 1; - - // If true, on a given page, there can be multiple `document` annotations - // covering it. - bool document_allow_multiple_labels = 2; - - // If set, all the nested entities must be prefixed with the parents. - bool prefixed_naming_on_properties = 6; - - // If set, we will skip the naming format validation in the schema. So the - // string values in `DocumentSchema.EntityType.name` and - // `DocumentSchema.EntityType.Property.name` will not be checked. - bool skip_naming_validation = 7; - } - - // Display name to show to users. - string display_name = 1; - - // Description of the schema. - string description = 2; - - // Entity types of the schema. - repeated EntityType entity_types = 3; - - // Metadata of the schema. - Metadata metadata = 4; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto deleted file mode 100644 index c42e0cb7a07..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/geometry.proto +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -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/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto deleted file mode 100644 index cd573a823c4..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/operation_metadata.proto +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -import "google/protobuf/timestamp.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; - - // A related resource to this operation. - string resource = 5; - - // The creation time of the operation. - google.protobuf.Timestamp create_time = 3; - - // The last update time of the operation. - google.protobuf.Timestamp update_time = 4; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto deleted file mode 100644 index db13e89defa..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor.proto +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/documentai/v1beta3/document_schema.proto"; -import "google/protobuf/timestamp.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"; - -// A processor version is an implementation of a processor. Each processor -// can have multiple versions, pre-trained by Google internally or up-trained -// by the customer. At a time, a processor can only have one default version -// version. So the processor's behavior (when processing documents) is defined -// by a default version -message ProcessorVersion { - option (google.api.resource) = { - type: "documentai.googleapis.com/ProcessorVersion" - pattern: "projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}" - }; - - // Information about the upcoming deprecation of this processor version. - message DeprecationInfo { - // The time at which this processor version will be deprecated. - google.protobuf.Timestamp deprecation_time = 1; - - // If set, the processor version that will be used as a replacement. - string replacement_processor_version = 2 [(google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - }]; - } - - // The possible states of the processor version. - enum State { - // The processor version is in an unspecified state. - STATE_UNSPECIFIED = 0; - - // The processor version is deployed and can be used for processing. - DEPLOYED = 1; - - // The processor version is being deployed. - DEPLOYING = 2; - - // The processor version is not deployed and cannot be used for processing. - UNDEPLOYED = 3; - - // The processor version is being undeployed. - UNDEPLOYING = 4; - - // The processor version is being created. - CREATING = 5; - - // The processor version is being deleted. - DELETING = 6; - - // The processor version failed and is in an indeterminate state. - FAILED = 7; - } - - // The resource name of the processor version. - // Format: - // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}` - string name = 1; - - // The display name of the processor version. - string display_name = 2; - - // The schema of the processor version. Describes the output. - DocumentSchema document_schema = 12; - - // The state of the processor version. - State state = 6; - - // The time the processor version was created. - google.protobuf.Timestamp create_time = 7; - - // The KMS key name used for encryption. - string kms_key_name = 9; - - // The KMS key version with which data is encrypted. - string kms_key_version_name = 10; - - // Denotes that this ProcessorVersion is managed by google. - bool google_managed = 11; - - // If set, information about the eventual deprecation of this version. - DeprecationInfo deprecation_info = 13; -} - -// The first-class citizen for Document AI. Each processor defines how to -// extract structural information from a document. -message Processor { - option (google.api.resource) = { - type: "documentai.googleapis.com/Processor" - pattern: "projects/{project}/locations/{location}/processors/{processor}" - }; - - // The possible states of the processor. - enum State { - // The processor is in an unspecified state. - STATE_UNSPECIFIED = 0; - - // The processor is enabled, i.e., has an enabled version which can - // currently serve processing requests and all the feature dependencies have - // been successfully initialized. - ENABLED = 1; - - // The processor is disabled. - DISABLED = 2; - - // The processor is being enabled, will become `ENABLED` if successful. - ENABLING = 3; - - // The processor is being disabled, will become `DISABLED` if successful. - DISABLING = 4; - - // The processor is being created, will become either `ENABLED` (for - // successful creation) or `FAILED` (for failed ones). - // Once a processor is in this state, it can then be used for document - // processing, but the feature dependencies of the processor might not be - // fully created yet. - CREATING = 5; - - // The processor failed during creation or initialization of feature - // dependencies. The user should delete the processor and recreate one as - // all the functionalities of the processor are disabled. - FAILED = 6; - - // The processor is being deleted, will be removed if successful. - DELETING = 7; - } - - // Output only. Immutable. The resource name of the processor. - // Format: `projects/{project}/locations/{location}/processors/{processor}` - string name = 1 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. - // To get a list of processors types, see - // [FetchProcessorTypes][google.cloud.documentai.v1beta3.DocumentProcessorService.FetchProcessorTypes]. - string type = 2; - - // The display name of the processor. - string display_name = 3; - - // Output only. The state of the processor. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The default processor version. - string default_processor_version = 9 [(google.api.resource_reference) = { - type: "documentai.googleapis.com/ProcessorVersion" - }]; - - // Output only. Immutable. The http endpoint that can be called to invoke processing. - string process_endpoint = 6 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.field_behavior) = IMMUTABLE - ]; - - // The time the processor was created. - google.protobuf.Timestamp create_time = 7; - - // The KMS key used for encryption/decryption in CMEK scenarios. - // See https://cloud.google.com/security-key-management. - string kms_key_name = 8; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto b/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto deleted file mode 100644 index 9afbf04d481..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/processor_type.proto +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.cloud.documentai.v1beta3; - -import "google/api/launch_stage.proto"; -import "google/api/resource.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, currently must be one of [us, eu]. - string location_id = 1; - } - - // The resource name of the processor type. - // Format: `projects/{project}/processorTypes/{processor_type}` - string name = 1; - - // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. - string type = 2; - - // The processor category, used by UI to group processor types. - string category = 3; - - // The locations in which this processor is available. - repeated LocationInfo available_locations = 4; - - // Whether the processor type allows creation. If true, users can create a - // processor of this processor type. Otherwise, users need to request access. - bool allow_creation = 6; - - // Launch stage of the processor type - google.api.LaunchStage launch_stage = 8; -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.batch_process_documents.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.batch_process_documents.js deleted file mode 100644 index 25bd5f659c2..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.batch_process_documents.js +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of Processor google.cloud.documentai.v1beta3.Processor or - * ProcessorVersion google.cloud.documentai.v1beta3.ProcessorVersion. - * Format: `projects/{project}/locations/{location}/processors/{processor}`, - * or - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - */ - // const name = 'abc123' - /** - * The input config for each single document in the batch process. - */ - // const inputConfigs = 1234 - /** - * The overall output config for batch process. - */ - // const outputConfig = {} - /** - * The input documents for batch process. - */ - // const inputDocuments = {} - /** - * The overall output config for batch process. - */ - // const documentOutputConfig = {} - /** - * Whether Human Review feature should be skipped for this request. Default to - * false. - */ - // const skipHumanReview = true - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callBatchProcessDocuments() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.batchProcessDocuments(request); - const [response] = await operation.promise(); - console.log(response); - } - - callBatchProcessDocuments(); - // [END documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.create_processor.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.create_processor.js deleted file mode 100644 index fc1916f0a92..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.create_processor.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, processor) { - // [START documentai_v1beta3_generated_DocumentProcessorService_CreateProcessor_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent (project and location) under which to create the processor. - * Format: `projects/{project}/locations/{location}` - */ - // const parent = 'abc123' - /** - * 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. - */ - // const processor = {} - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callCreateProcessor() { - // Construct request - const request = { - parent, - processor, - }; - - // Run request - const response = await documentaiClient.createProcessor(request); - console.log(response); - } - - callCreateProcessor(); - // [END documentai_v1beta3_generated_DocumentProcessorService_CreateProcessor_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor.js deleted file mode 100644 index ae5e7227c34..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor resource name to be deleted. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callDeleteProcessor() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.deleteProcessor(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteProcessor(); - // [END documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor_version.js deleted file mode 100644 index a2c34c8befc..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.delete_processor_version.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessorVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor version resource name to be deleted. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callDeleteProcessorVersion() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.deleteProcessorVersion(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteProcessorVersion(); - // [END documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessorVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.deploy_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.deploy_processor_version.js deleted file mode 100644 index 416d46b66b0..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.deploy_processor_version.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1beta3_generated_DocumentProcessorService_DeployProcessorVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor version resource name to be deployed. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callDeployProcessorVersion() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.deployProcessorVersion(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeployProcessorVersion(); - // [END documentai_v1beta3_generated_DocumentProcessorService_DeployProcessorVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.disable_processor.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.disable_processor.js deleted file mode 100644 index 2fa77f79000..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.disable_processor.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor resource name to be disabled. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callDisableProcessor() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.disableProcessor(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDisableProcessor(); - // [END documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.enable_processor.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.enable_processor.js deleted file mode 100644 index e2ee9079f41..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.enable_processor.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor resource name to be enabled. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callEnableProcessor() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.enableProcessor(request); - const [response] = await operation.promise(); - console.log(response); - } - - callEnableProcessor(); - // [END documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js deleted file mode 100644 index 4fc8c1275e3..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START documentai_v1beta3_generated_DocumentProcessorService_FetchProcessorTypes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - */ - // const parent = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callFetchProcessorTypes() { - // Construct request - const request = { - parent, - }; - - // Run request - const response = await documentaiClient.fetchProcessorTypes(request); - console.log(response); - } - - callFetchProcessorTypes(); - // [END documentai_v1beta3_generated_DocumentProcessorService_FetchProcessorTypes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor.js deleted file mode 100644 index 4b89803a0c3..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1beta3_generated_DocumentProcessorService_GetProcessor_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor resource name. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callGetProcessor() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await documentaiClient.getProcessor(request); - console.log(response); - } - - callGetProcessor(); - // [END documentai_v1beta3_generated_DocumentProcessorService_GetProcessor_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor_version.js deleted file mode 100644 index 9c30f2d02fd..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_processor_version.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1beta3_generated_DocumentProcessorService_GetProcessorVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor resource name. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callGetProcessorVersion() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await documentaiClient.getProcessorVersion(request); - console.log(response); - } - - callGetProcessorVersion(); - // [END documentai_v1beta3_generated_DocumentProcessorService_GetProcessorVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_types.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_types.js deleted file mode 100644 index 7500d1d6dd7..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_types.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START documentai_v1beta3_generated_DocumentProcessorService_ListProcessorTypes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The location of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - */ - // const parent = 'abc123' - /** - * The maximum number of processor types to return. - * If unspecified, at most 100 processor types will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - */ - // const pageSize = 1234 - /** - * Used to retrieve the next page of results, empty if at the end of the list. - */ - // const pageToken = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callListProcessorTypes() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await documentaiClient.listProcessorTypesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProcessorTypes(); - // [END documentai_v1beta3_generated_DocumentProcessorService_ListProcessorTypes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_versions.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_versions.js deleted file mode 100644 index c922f46fadc..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processor_versions.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START documentai_v1beta3_generated_DocumentProcessorService_ListProcessorVersions_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent (project, location and processor) to list all versions. - * Format: `projects/{project}/locations/{location}/processors/{processor}` - */ - // const parent = 'abc123' - /** - * The maximum number of processor versions to return. - * If unspecified, at most 10 processor versions will be returned. - * The maximum value is 20; values above 20 will be coerced to 20. - */ - // const pageSize = 1234 - /** - * We will return the processor versions sorted by creation time. The page - * token will point to the next processor version. - */ - // const pageToken = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callListProcessorVersions() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await documentaiClient.listProcessorVersionsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProcessorVersions(); - // [END documentai_v1beta3_generated_DocumentProcessorService_ListProcessorVersions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processors.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processors.js deleted file mode 100644 index c136a802329..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_processors.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START documentai_v1beta3_generated_DocumentProcessorService_ListProcessors_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent (project and location) which owns this collection of Processors. - * Format: `projects/{project}/locations/{location}` - */ - // const parent = 'abc123' - /** - * 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. - */ - // const pageSize = 1234 - /** - * We will return the processors sorted by creation time. The page token - * will point to the next processor. - */ - // const pageToken = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callListProcessors() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await documentaiClient.listProcessorsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProcessors(); - // [END documentai_v1beta3_generated_DocumentProcessorService_ListProcessors_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.process_document.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.process_document.js deleted file mode 100644 index b64abecbc4c..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.process_document.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1beta3_generated_DocumentProcessorService_ProcessDocument_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * An inline document proto. - */ - // const inlineDocument = {} - /** - * A raw document content (bytes). - */ - // const rawDocument = {} - /** - * Required. The resource name of the Processor google.cloud.documentai.v1beta3.Processor or - * ProcessorVersion google.cloud.documentai.v1beta3.ProcessorVersion - * to use for processing. If a Processor google.cloud.documentai.v1beta3.Processor is specified, the server will use - * its default version google.cloud.documentai.v1beta3.Processor.default_processor_version. Format: - * `projects/{project}/locations/{location}/processors/{processor}`, or - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - */ - // const name = 'abc123' - /** - * The document payload, the content and mime_type fields must be set. - */ - // const document = {} - /** - * Whether Human Review feature should be skipped for this request. Default to - * false. - */ - // const skipHumanReview = true - /** - * Specifies which fields to include in ProcessResponse's document. - * Only supports top level document and pages field so it must be in the form - * of `{document_field_name}` or `pages.{page_field_name}`. - */ - // const fieldMask = {} - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callProcessDocument() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await documentaiClient.processDocument(request); - console.log(response); - } - - callProcessDocument(); - // [END documentai_v1beta3_generated_DocumentProcessorService_ProcessDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.review_document.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.review_document.js deleted file mode 100644 index cb7b942ae57..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.review_document.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(humanReviewConfig) { - // [START documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * An inline document proto. - */ - // const inlineDocument = {} - /** - * Required. The resource name of the HumanReviewConfig that the document will be - * reviewed with. - */ - // const humanReviewConfig = 'abc123' - /** - * The document that needs human review. - */ - // const document = {} - /** - * Whether the validation should be performed on the ad-hoc review request. - */ - // const enableSchemaValidation = true - /** - * The priority of the human review task. - */ - // const priority = {} - /** - * The document schema of the human review task. - */ - // const documentSchema = {} - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callReviewDocument() { - // Construct request - const request = { - humanReviewConfig, - }; - - // Run request - const [operation] = await documentaiClient.reviewDocument(request); - const [response] = await operation.promise(); - console.log(response); - } - - callReviewDocument(); - // [END documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.set_default_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.set_default_processor_version.js deleted file mode 100644 index 44d9177db6b..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.set_default_processor_version.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(processor, defaultProcessorVersion) { - // [START documentai_v1beta3_generated_DocumentProcessorService_SetDefaultProcessorVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Processor google.cloud.documentai.v1beta3.Processor to change default version. - */ - // const processor = 'abc123' - /** - * Required. The resource name of child ProcessorVersion google.cloud.documentai.v1beta3.ProcessorVersion to use as default. - * Format: - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` - */ - // const defaultProcessorVersion = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callSetDefaultProcessorVersion() { - // Construct request - const request = { - processor, - defaultProcessorVersion, - }; - - // Run request - const [operation] = await documentaiClient.setDefaultProcessorVersion(request); - const [response] = await operation.promise(); - console.log(response); - } - - callSetDefaultProcessorVersion(); - // [END documentai_v1beta3_generated_DocumentProcessorService_SetDefaultProcessorVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js deleted file mode 100644 index 6bc7a006fb6..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START documentai_v1beta3_generated_DocumentProcessorService_UndeployProcessorVersion_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The processor version resource name to be undeployed. - */ - // const name = 'abc123' - - // Imports the Documentai library - const {DocumentProcessorServiceClient} = require('@google-cloud/documentai').v1beta3; - - // Instantiates a client - const documentaiClient = new DocumentProcessorServiceClient(); - - async function callUndeployProcessorVersion() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await documentaiClient.undeployProcessorVersion(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUndeployProcessorVersion(); - // [END documentai_v1beta3_generated_DocumentProcessorService_UndeployProcessorVersion_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json b/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json deleted file mode 100644 index 96ed239b5ff..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json +++ /dev/null @@ -1,975 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-documentai", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.documentai.v1beta3", - "version": "v1beta3" - } - ] - }, - "snippets": [ - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ProcessDocument_async", - "title": "DocumentProcessorService processDocument Sample", - "origin": "API_DEFINITION", - "description": " Processes a single document.", - "canonical": true, - "file": "document_processor_service.process_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 81, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ProcessDocument", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument", - "async": true, - "parameters": [ - { - "name": "inline_document", - "type": ".google.cloud.documentai.v1beta3.Document" - }, - { - "name": "raw_document", - "type": ".google.cloud.documentai.v1beta3.RawDocument" - }, - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "document", - "type": ".google.cloud.documentai.v1beta3.Document" - }, - { - "name": "skip_human_review", - "type": "TYPE_BOOL" - }, - { - "name": "field_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.documentai.v1beta3.ProcessResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ProcessDocument", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async", - "title": "DocumentProcessorService batchProcessDocuments Sample", - "origin": "API_DEFINITION", - "description": " LRO endpoint to batch process many documents. The output is written to Cloud Storage as JSON in the [Document] format.", - "canonical": true, - "file": "document_processor_service.batch_process_documents.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 79, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchProcessDocuments", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "input_configs", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "output_config", - "type": ".google.cloud.documentai.v1beta3.BatchProcessRequest.BatchOutputConfig" - }, - { - "name": "input_documents", - "type": ".google.cloud.documentai.v1beta3.BatchDocumentsInputConfig" - }, - { - "name": "document_output_config", - "type": ".google.cloud.documentai.v1beta3.DocumentOutputConfig" - }, - { - "name": "skip_human_review", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "BatchProcessDocuments", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_FetchProcessorTypes_async", - "title": "DocumentProcessorService fetchProcessorTypes Sample", - "origin": "API_DEFINITION", - "description": " Fetches processor types. Note that we do not use ListProcessorTypes here because it is not paginated.", - "canonical": true, - "file": "document_processor_service.fetch_processor_types.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "FetchProcessorTypes", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.FetchProcessorTypes", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1beta3.FetchProcessorTypesResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "FetchProcessorTypes", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.FetchProcessorTypes", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListProcessorTypes_async", - "title": "DocumentProcessorService listProcessorTypes Sample", - "origin": "API_DEFINITION", - "description": " Lists the processor types that exist.", - "canonical": true, - "file": "document_processor_service.list_processor_types.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProcessorTypes", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessorTypes", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1beta3.ListProcessorTypesResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ListProcessorTypes", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessorTypes", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListProcessors_async", - "title": "DocumentProcessorService listProcessors Sample", - "origin": "API_DEFINITION", - "description": " Lists all processors which belong to this project.", - "canonical": true, - "file": "document_processor_service.list_processors.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProcessors", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessors", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1beta3.ListProcessorsResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ListProcessors", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessors", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_GetProcessor_async", - "title": "DocumentProcessorService getProcessor Sample", - "origin": "API_DEFINITION", - "description": " Gets a processor detail.", - "canonical": true, - "file": "document_processor_service.get_processor.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProcessor", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetProcessor", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1beta3.Processor", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "GetProcessor", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetProcessor", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async", - "title": "DocumentProcessorService trainProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Trains a new processor version. Operation metadata is returned as cloud_documentai_core.TrainProcessorVersionMetadata.", - "canonical": true, - "file": "document_processor_service.train_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 74, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TrainProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.TrainProcessorVersion", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "processor_version", - "type": ".google.cloud.documentai.v1beta3.ProcessorVersion" - }, - { - "name": "document_schema", - "type": ".google.cloud.documentai.v1beta3.DocumentSchema" - }, - { - "name": "input_data", - "type": ".google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData" - }, - { - "name": "base_processor_version", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "TrainProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.TrainProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_GetProcessorVersion_async", - "title": "DocumentProcessorService getProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Gets a processor version detail.", - "canonical": true, - "file": "document_processor_service.get_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetProcessorVersion", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1beta3.ProcessorVersion", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "GetProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListProcessorVersions_async", - "title": "DocumentProcessorService listProcessorVersions Sample", - "origin": "API_DEFINITION", - "description": " Lists all versions of a processor.", - "canonical": true, - "file": "document_processor_service.list_processor_versions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProcessorVersions", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessorVersions", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1beta3.ListProcessorVersionsResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ListProcessorVersions", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListProcessorVersions", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessorVersion_async", - "title": "DocumentProcessorService deleteProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Deletes the processor version, all artifacts under the processor version will be deleted.", - "canonical": true, - "file": "document_processor_service.delete_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeleteProcessorVersion", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "DeleteProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeleteProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DeployProcessorVersion_async", - "title": "DocumentProcessorService deployProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Deploys the processor version.", - "canonical": true, - "file": "document_processor_service.deploy_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeployProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeployProcessorVersion", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "DeployProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeployProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_UndeployProcessorVersion_async", - "title": "DocumentProcessorService undeployProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Undeploys the processor version.", - "canonical": true, - "file": "document_processor_service.undeploy_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UndeployProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.UndeployProcessorVersion", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "UndeployProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.UndeployProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_CreateProcessor_async", - "title": "DocumentProcessorService createProcessor Sample", - "origin": "API_DEFINITION", - "description": " Creates a processor from the type processor that the user chose. The processor will be at \"ENABLED\" state by default after its creation.", - "canonical": true, - "file": "document_processor_service.create_processor.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProcessor", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.CreateProcessor", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "processor", - "type": ".google.cloud.documentai.v1beta3.Processor" - } - ], - "resultType": ".google.cloud.documentai.v1beta3.Processor", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "CreateProcessor", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.CreateProcessor", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async", - "title": "DocumentProcessorService deleteProcessor Sample", - "origin": "API_DEFINITION", - "description": " Deletes the processor, unloads all deployed model artifacts if it was enabled and then deletes all artifacts associated with this processor.", - "canonical": true, - "file": "document_processor_service.delete_processor.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProcessor", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeleteProcessor", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "DeleteProcessor", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DeleteProcessor", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async", - "title": "DocumentProcessorService enableProcessor Sample", - "origin": "API_DEFINITION", - "description": " Enables a processor", - "canonical": true, - "file": "document_processor_service.enable_processor.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "EnableProcessor", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EnableProcessor", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "EnableProcessor", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EnableProcessor", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async", - "title": "DocumentProcessorService disableProcessor Sample", - "origin": "API_DEFINITION", - "description": " Disables a processor", - "canonical": true, - "file": "document_processor_service.disable_processor.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DisableProcessor", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DisableProcessor", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "DisableProcessor", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.DisableProcessor", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_SetDefaultProcessorVersion_async", - "title": "DocumentProcessorService setDefaultProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Set the default (active) version of a [Processor][google.cloud.documentai.v1beta3.Processor] that will be used in [ProcessDocument][google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument] and [BatchProcessDocuments][google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments].", - "canonical": true, - "file": "document_processor_service.set_default_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetDefaultProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.SetDefaultProcessorVersion", - "async": true, - "parameters": [ - { - "name": "processor", - "type": "TYPE_STRING" - }, - { - "name": "default_processor_version", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "SetDefaultProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.SetDefaultProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async", - "title": "DocumentProcessorService reviewDocument Sample", - "origin": "API_DEFINITION", - "description": " Send a document for Human Review. The input document should be processed by the specified processor.", - "canonical": true, - "file": "document_processor_service.review_document.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReviewDocument", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ReviewDocument", - "async": true, - "parameters": [ - { - "name": "inline_document", - "type": ".google.cloud.documentai.v1beta3.Document" - }, - { - "name": "human_review_config", - "type": "TYPE_STRING" - }, - { - "name": "document", - "type": ".google.cloud.documentai.v1beta3.Document" - }, - { - "name": "enable_schema_validation", - "type": "TYPE_BOOL" - }, - { - "name": "priority", - "type": ".google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority" - }, - { - "name": "document_schema", - "type": ".google.cloud.documentai.v1beta3.DocumentSchema" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ReviewDocument", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ReviewDocument", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async", - "title": "DocumentProcessorService evaluateProcessorVersion Sample", - "origin": "API_DEFINITION", - "description": " Evaluates a ProcessorVersion against annotated documents, producing an Evaluation.", - "canonical": true, - "file": "document_processor_service.evaluate_processor_version.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "EvaluateProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EvaluateProcessorVersion", - "async": true, - "parameters": [ - { - "name": "processor_version", - "type": "TYPE_STRING" - }, - { - "name": "evaluation_documents", - "type": ".google.cloud.documentai.v1beta3.BatchDocumentsInputConfig" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "EvaluateProcessorVersion", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EvaluateProcessorVersion", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_GetEvaluation_async", - "title": "DocumentProcessorService getEvaluation Sample", - "origin": "API_DEFINITION", - "description": " Retrieves a specific evaluation.", - "canonical": true, - "file": "document_processor_service.get_evaluation.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetEvaluation", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetEvaluation", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1beta3.Evaluation", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "GetEvaluation", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetEvaluation", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - }, - { - "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListEvaluations_async", - "title": "DocumentProcessorService listEvaluations Sample", - "origin": "API_DEFINITION", - "description": " Retrieves a set of evaluations for a given processor version.", - "canonical": true, - "file": "document_processor_service.list_evaluations.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListEvaluations", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListEvaluations", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.documentai.v1beta3.ListEvaluationsResponse", - "client": { - "shortName": "DocumentProcessorServiceClient", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" - }, - "method": { - "shortName": "ListEvaluations", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListEvaluations", - "service": { - "shortName": "DocumentProcessorService", - "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" - } - } - } - } - ] -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/src/index.ts deleted file mode 100644 index 1910b60fddc..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as 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/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts deleted file mode 100644 index 06dca98717e..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client.ts +++ /dev/null @@ -1,3324 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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'; -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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new DocumentProcessorServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - evaluationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation}' - ), - 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}' - ), - processorVersionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}' - ), - 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 = { - listProcessorTypes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processorTypes'), - listProcessors: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processors'), - listProcessorVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'processorVersions'), - listEvaluations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'evaluations') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta3/{name=projects/*/locations/*}',additional_bindings: [{get: '/uiv1beta3/{name=projects/*/locations/*}',}], - },{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta3/{name=projects/*}/locations',additional_bindings: [{get: '/uiv1beta3/{name=projects/*}/locations',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta3/{name=projects/*/locations/*/operations/*}:cancel',additional_bindings: [{post: '/uiv1beta3/{name=projects/*/locations/*/operations/*}:cancel',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta3/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/uiv1beta3/{name=projects/*/locations/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta3/{name=projects/*/locations/*/operations}',additional_bindings: [{get: '/uiv1beta3/{name=projects/*/locations/*/operations}',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 trainProcessorVersionResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.TrainProcessorVersionResponse') as gax.protobuf.Type; - const trainProcessorVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata') as gax.protobuf.Type; - const deleteProcessorVersionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteProcessorVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.DeleteProcessorVersionMetadata') as gax.protobuf.Type; - const deployProcessorVersionResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.DeployProcessorVersionResponse') as gax.protobuf.Type; - const deployProcessorVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.DeployProcessorVersionMetadata') as gax.protobuf.Type; - const undeployProcessorVersionResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.UndeployProcessorVersionResponse') as gax.protobuf.Type; - const undeployProcessorVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.UndeployProcessorVersionMetadata') 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 setDefaultProcessorVersionResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionResponse') as gax.protobuf.Type; - const setDefaultProcessorVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionMetadata') 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; - const evaluateProcessorVersionResponse = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse') as gax.protobuf.Type; - const evaluateProcessorVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - batchProcessDocumentsResponse.decode.bind(batchProcessDocumentsResponse), - batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata)), - trainProcessorVersion: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - trainProcessorVersionResponse.decode.bind(trainProcessorVersionResponse), - trainProcessorVersionMetadata.decode.bind(trainProcessorVersionMetadata)), - deleteProcessorVersion: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteProcessorVersionResponse.decode.bind(deleteProcessorVersionResponse), - deleteProcessorVersionMetadata.decode.bind(deleteProcessorVersionMetadata)), - deployProcessorVersion: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deployProcessorVersionResponse.decode.bind(deployProcessorVersionResponse), - deployProcessorVersionMetadata.decode.bind(deployProcessorVersionMetadata)), - undeployProcessorVersion: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - undeployProcessorVersionResponse.decode.bind(undeployProcessorVersionResponse), - undeployProcessorVersionMetadata.decode.bind(undeployProcessorVersionMetadata)), - 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)), - setDefaultProcessorVersion: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - setDefaultProcessorVersionResponse.decode.bind(setDefaultProcessorVersionResponse), - setDefaultProcessorVersionMetadata.decode.bind(setDefaultProcessorVersionMetadata)), - reviewDocument: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - reviewDocumentResponse.decode.bind(reviewDocumentResponse), - reviewDocumentMetadata.decode.bind(reviewDocumentMetadata)), - evaluateProcessorVersion: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - evaluateProcessorVersionResponse.decode.bind(evaluateProcessorVersionResponse), - evaluateProcessorVersionMetadata.decode.bind(evaluateProcessorVersionMetadata)) - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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', 'listProcessorTypes', 'listProcessors', 'getProcessor', 'trainProcessorVersion', 'getProcessorVersion', 'listProcessorVersions', 'deleteProcessorVersion', 'deployProcessorVersion', 'undeployProcessorVersion', 'createProcessor', 'deleteProcessor', 'enableProcessor', 'disableProcessor', 'setDefaultProcessorVersion', 'reviewDocument', 'evaluateProcessorVersion', 'getEvaluation', 'listEvaluations']; - 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._opts.fallback - ); - - 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 -- - // ------------------- -/** - * 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 resource name of the {@link google.cloud.documentai.v1beta3.Processor|Processor} or - * {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} - * to use for processing. If a {@link google.cloud.documentai.v1beta3.Processor|Processor} is specified, the server will use - * its {@link google.cloud.documentai.v1beta3.Processor.default_processor_version|default version}. Format: - * `projects/{project}/locations/{location}/processors/{processor}`, or - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - * @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 {google.protobuf.FieldMask} request.fieldMask - * Specifies which fields to include in ProcessResponse's document. - * Only supports top level document and pages field so it must be in the form - * of `{document_field_name}` or `pages.{page_field_name}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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 include:samples/generated/v1beta3/document_processor_service.process_document.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ProcessDocument_async - */ - 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; - 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.processDocument(request, options, callback); - } -/** - * Fetches processor types. Note that we do not use ListProcessorTypes here - * because it is not paginated. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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 include:samples/generated/v1beta3/document_processor_service.fetch_processor_types.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_FetchProcessorTypes_async - */ - 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; - 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.fetchProcessorTypes(request, options, callback); - } -/** - * Gets a processor detail. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.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 include:samples/generated/v1beta3/document_processor_service.get_processor.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_GetProcessor_async - */ - getProcessor( - request?: protos.google.cloud.documentai.v1beta3.IGetProcessorRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|undefined, {}|undefined - ]>; - getProcessor( - request: protos.google.cloud.documentai.v1beta3.IGetProcessorRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|null|undefined, - {}|null|undefined>): void; - getProcessor( - request: protos.google.cloud.documentai.v1beta3.IGetProcessorRequest, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|null|undefined, - {}|null|undefined>): void; - getProcessor( - request?: protos.google.cloud.documentai.v1beta3.IGetProcessorRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessor, - protos.google.cloud.documentai.v1beta3.IGetProcessorRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProcessor(request, options, callback); - } -/** - * Gets a processor version detail. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor resource name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ProcessorVersion]{@link google.cloud.documentai.v1beta3.ProcessorVersion}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.get_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_GetProcessorVersion_async - */ - getProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessorVersion, - protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|undefined, {}|undefined - ]>; - getProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IProcessorVersion, - protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|null|undefined, - {}|null|undefined>): void; - getProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IProcessorVersion, - protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|null|undefined, - {}|null|undefined>): void; - getProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1beta3.IProcessorVersion, - protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1beta3.IProcessorVersion, - protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessorVersion, - protos.google.cloud.documentai.v1beta3.IGetProcessorVersionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getProcessorVersion(request, options, callback); - } -/** - * 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 include:samples/generated/v1beta3/document_processor_service.create_processor.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_CreateProcessor_async - */ - 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; - 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createProcessor(request, options, callback); - } -/** - * Retrieves a specific evaluation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the {@link google.cloud.documentai.v1beta3.Evaluation|Evaluation} to get. - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.get_evaluation.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_GetEvaluation_async - */ - getEvaluation( - request?: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta3.IEvaluation, - protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|undefined, {}|undefined - ]>; - getEvaluation( - request: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IEvaluation, - protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|null|undefined, - {}|null|undefined>): void; - getEvaluation( - request: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, - callback: Callback< - protos.google.cloud.documentai.v1beta3.IEvaluation, - protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|null|undefined, - {}|null|undefined>): void; - getEvaluation( - request?: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.documentai.v1beta3.IEvaluation, - protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.documentai.v1beta3.IEvaluation, - protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.documentai.v1beta3.IEvaluation, - protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getEvaluation(request, options, callback); - } - -/** - * 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 resource name of {@link google.cloud.documentai.v1beta3.Processor|Processor} or - * {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion}. - * Format: `projects/{project}/locations/{location}/processors/{processor}`, - * or - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - * @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 include:samples/generated/v1beta3/document_processor_service.batch_process_documents.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async - */ - 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; - 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' - ] = this._gaxModule.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 include:samples/generated/v1beta3/document_processor_service.batch_process_documents.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_BatchProcessDocuments_async - */ - async checkBatchProcessDocumentsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchProcessDocuments, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Trains a new processor version. - * Operation metadata is returned as - * cloud_documentai_core.TrainProcessorVersionMetadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project, location and processor) to create the new version for. - * Format: `projects/{project}/locations/{location}/processors/{processor}`. - * @param {google.cloud.documentai.v1beta3.ProcessorVersion} request.processorVersion - * Required. The processor version to be created. - * @param {google.cloud.documentai.v1beta3.DocumentSchema} [request.documentSchema] - * Optional. The schema the processor version will be trained with. - * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData} [request.inputData] - * Optional. The input data used to train the `ProcessorVersion`. - * @param {string} [request.baseProcessorVersion] - * Optional. The processor version to use as a base for training. This processor version - * must be a child of `parent`. Format: - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.train_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async - */ - trainProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - trainProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - trainProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - trainProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.trainProcessorVersion(request, options, callback); - } -/** - * Check the status of the long running operation returned by `trainProcessorVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.train_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async - */ - async checkTrainProcessorVersionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.trainProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes the processor version, all artifacts under the processor version - * will be deleted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor version 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 include:samples/generated/v1beta3/document_processor_service.delete_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessorVersion_async - */ - deleteProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteProcessorVersion(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteProcessorVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.delete_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessorVersion_async - */ - async checkDeleteProcessorVersionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deploys the processor version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor version resource name to be deployed. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.deploy_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeployProcessorVersion_async - */ - deployProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deployProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deployProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deployProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deployProcessorVersion(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deployProcessorVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.deploy_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeployProcessorVersion_async - */ - async checkDeployProcessorVersionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deployProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Undeploys the processor version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The processor version resource name to be undeployed. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_UndeployProcessorVersion_async - */ - undeployProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.IUndeployProcessorVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - undeployProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.IUndeployProcessorVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeployProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.IUndeployProcessorVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeployProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.IUndeployProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.undeployProcessorVersion(request, options, callback); - } -/** - * Check the status of the long running operation returned by `undeployProcessorVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_UndeployProcessorVersion_async - */ - async checkUndeployProcessorVersionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.undeployProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * 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 include:samples/generated/v1beta3/document_processor_service.delete_processor.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async - */ - 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; - 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' - ] = this._gaxModule.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 include:samples/generated/v1beta3/document_processor_service.delete_processor.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DeleteProcessor_async - */ - async checkDeleteProcessorProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteProcessor, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * 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 include:samples/generated/v1beta3/document_processor_service.enable_processor.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async - */ - 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; - 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' - ] = this._gaxModule.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 include:samples/generated/v1beta3/document_processor_service.enable_processor.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_EnableProcessor_async - */ - async checkEnableProcessorProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.enableProcessor, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * 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 include:samples/generated/v1beta3/document_processor_service.disable_processor.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async - */ - 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; - 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' - ] = this._gaxModule.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 include:samples/generated/v1beta3/document_processor_service.disable_processor.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_DisableProcessor_async - */ - async checkDisableProcessorProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.disableProcessor, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Set the default (active) version of a {@link google.cloud.documentai.v1beta3.Processor|Processor} that will be used in - * {@link google.cloud.documentai.v1beta3.DocumentProcessorService.ProcessDocument|ProcessDocument} and - * {@link google.cloud.documentai.v1beta3.DocumentProcessorService.BatchProcessDocuments|BatchProcessDocuments}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.processor - * Required. The resource name of the {@link google.cloud.documentai.v1beta3.Processor|Processor} to change default version. - * @param {string} request.defaultProcessorVersion - * Required. The resource name of child {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to use as default. - * Format: - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{version}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.set_default_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_SetDefaultProcessorVersion_async - */ - setDefaultProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.ISetDefaultProcessorVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - setDefaultProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.ISetDefaultProcessorVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setDefaultProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.ISetDefaultProcessorVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - setDefaultProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.ISetDefaultProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'processor': request.processor ?? '', - }); - this.initialize(); - return this.innerApiCalls.setDefaultProcessorVersion(request, options, callback); - } -/** - * Check the status of the long running operation returned by `setDefaultProcessorVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.set_default_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_SetDefaultProcessorVersion_async - */ - async checkSetDefaultProcessorVersionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.setDefaultProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * 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 {google.cloud.documentai.v1beta3.DocumentSchema} request.documentSchema - * The document schema 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 include:samples/generated/v1beta3/document_processor_service.review_document.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async - */ - 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; - 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' - ] = this._gaxModule.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 include:samples/generated/v1beta3/document_processor_service.review_document.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ReviewDocument_async - */ - async checkReviewDocumentProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.reviewDocument, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Evaluates a ProcessorVersion against annotated documents, producing an - * Evaluation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.processorVersion - * Required. The resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to evaluate. - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - * @param {google.cloud.documentai.v1beta3.BatchDocumentsInputConfig} [request.evaluationDocuments] - * Optional. The documents used in the evaluation. If unspecified, use the processor's - * dataset as evaluation input. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async - */ - evaluateProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - evaluateProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - evaluateProcessorVersion( - request: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - evaluateProcessorVersion( - request?: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'processor_version': request.processorVersion ?? '', - }); - this.initialize(); - return this.innerApiCalls.evaluateProcessorVersion(request, options, callback); - } -/** - * Check the status of the long running operation returned by `evaluateProcessorVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async - */ - async checkEvaluateProcessorVersionProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.evaluateProcessorVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the processor types that exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - * @param {number} request.pageSize - * The maximum number of processor types to return. - * If unspecified, at most 100 processor types will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - * @param {string} request.pageToken - * Used to retrieve the next page of results, empty if at the end of the list. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ProcessorType]{@link google.cloud.documentai.v1beta3.ProcessorType}. - * 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 `listProcessorTypesAsync()` - * 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. - */ - listProcessorTypes( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessorType[], - protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest|null, - protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse - ]>; - listProcessorTypes( - request: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessorType>): void; - listProcessorTypes( - request: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, - callback: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessorType>): void; - listProcessorTypes( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessorType>, - callback?: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessorType>): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessorType[], - protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest|null, - protos.google.cloud.documentai.v1beta3.IListProcessorTypesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProcessorTypes(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 location of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - * @param {number} request.pageSize - * The maximum number of processor types to return. - * If unspecified, at most 100 processor types will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - * @param {string} request.pageToken - * Used to retrieve the next page of results, empty if at the end of the list. - * @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 [ProcessorType]{@link google.cloud.documentai.v1beta3.ProcessorType} 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 `listProcessorTypesAsync()` - * 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. - */ - listProcessorTypesStream( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessorTypes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessorTypes.createStream( - this.innerApiCalls.listProcessorTypes as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProcessorTypes`, 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 location of processor type to list. - * The available processor types may depend on the allow-listing on projects. - * Format: `projects/{project}/locations/{location}` - * @param {number} request.pageSize - * The maximum number of processor types to return. - * If unspecified, at most 100 processor types will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - * @param {string} request.pageToken - * Used to retrieve the next page of results, empty if at the end of the list. - * @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 - * [ProcessorType]{@link google.cloud.documentai.v1beta3.ProcessorType}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.list_processor_types.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ListProcessorTypes_async - */ - listProcessorTypesAsync( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorTypesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessorTypes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessorTypes.asyncIterate( - this.innerApiCalls['listProcessorTypes'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * 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, - 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; - 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' - ] = this._gaxModule.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessors']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessors.createStream( - this.innerApiCalls.listProcessors as 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 include:samples/generated/v1beta3/document_processor_service.list_processors.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ListProcessors_async - */ - 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessors']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessors.asyncIterate( - this.innerApiCalls['listProcessors'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Lists all versions of a processor. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project, location and processor) to list all versions. - * Format: `projects/{project}/locations/{location}/processors/{processor}` - * @param {number} request.pageSize - * The maximum number of processor versions to return. - * If unspecified, at most 10 processor versions will be returned. - * The maximum value is 20; values above 20 will be coerced to 20. - * @param {string} request.pageToken - * We will return the processor versions sorted by creation time. The page - * token will point to the next processor version. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 [ProcessorVersion]{@link google.cloud.documentai.v1beta3.ProcessorVersion}. - * 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 `listProcessorVersionsAsync()` - * 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. - */ - listProcessorVersions( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessorVersion[], - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest|null, - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse - ]>; - listProcessorVersions( - request: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessorVersion>): void; - listProcessorVersions( - request: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessorVersion>): void; - listProcessorVersions( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessorVersion>, - callback?: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IProcessorVersion>): - Promise<[ - protos.google.cloud.documentai.v1beta3.IProcessorVersion[], - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest|null, - protos.google.cloud.documentai.v1beta3.IListProcessorVersionsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProcessorVersions(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, location and processor) to list all versions. - * Format: `projects/{project}/locations/{location}/processors/{processor}` - * @param {number} request.pageSize - * The maximum number of processor versions to return. - * If unspecified, at most 10 processor versions will be returned. - * The maximum value is 20; values above 20 will be coerced to 20. - * @param {string} request.pageToken - * We will return the processor versions sorted by creation time. The page - * token will point to the next processor version. - * @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 [ProcessorVersion]{@link google.cloud.documentai.v1beta3.ProcessorVersion} 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 `listProcessorVersionsAsync()` - * 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. - */ - listProcessorVersionsStream( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessorVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessorVersions.createStream( - this.innerApiCalls.listProcessorVersions as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProcessorVersions`, 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, location and processor) to list all versions. - * Format: `projects/{project}/locations/{location}/processors/{processor}` - * @param {number} request.pageSize - * The maximum number of processor versions to return. - * If unspecified, at most 10 processor versions will be returned. - * The maximum value is 20; values above 20 will be coerced to 20. - * @param {string} request.pageToken - * We will return the processor versions sorted by creation time. The page - * token will point to the next processor version. - * @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 - * [ProcessorVersion]{@link google.cloud.documentai.v1beta3.ProcessorVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.list_processor_versions.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ListProcessorVersions_async - */ - listProcessorVersionsAsync( - request?: protos.google.cloud.documentai.v1beta3.IListProcessorVersionsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProcessorVersions']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProcessorVersions.asyncIterate( - this.innerApiCalls['listProcessorVersions'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } - /** - * Retrieves a set of evaluations for a given processor version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to list evaluations for. - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - * @param {number} request.pageSize - * The standard list page size. - * If unspecified, at most 5 evaluations will be returned. - * The maximum value is 100; values above 100 will be coerced to 100. - * @param {string} request.pageToken - * A page token, received from a previous `ListEvaluations` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation}. - * 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 `listEvaluationsAsync()` - * 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. - */ - listEvaluations( - request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.documentai.v1beta3.IEvaluation[], - protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest|null, - protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse - ]>; - listEvaluations( - request: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, - protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IEvaluation>): void; - listEvaluations( - request: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, - callback: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, - protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IEvaluation>): void; - listEvaluations( - request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, - protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IEvaluation>, - callback?: PaginationCallback< - protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, - protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse|null|undefined, - protos.google.cloud.documentai.v1beta3.IEvaluation>): - Promise<[ - protos.google.cloud.documentai.v1beta3.IEvaluation[], - protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest|null, - protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listEvaluations(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 resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to list evaluations for. - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - * @param {number} request.pageSize - * The standard list page size. - * If unspecified, at most 5 evaluations will be returned. - * The maximum value is 100; values above 100 will be coerced to 100. - * @param {string} request.pageToken - * A page token, received from a previous `ListEvaluations` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation} 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 `listEvaluationsAsync()` - * 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. - */ - listEvaluationsStream( - request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listEvaluations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEvaluations.createStream( - this.innerApiCalls.listEvaluations as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listEvaluations`, 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 resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to list evaluations for. - * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` - * @param {number} request.pageSize - * The standard list page size. - * If unspecified, at most 5 evaluations will be returned. - * The maximum value is 100; values above 100 will be coerced to 100. - * @param {string} request.pageToken - * A page token, received from a previous `ListEvaluations` call. - * Provide this to retrieve the subsequent page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1beta3/document_processor_service.list_evaluations.js - * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ListEvaluations_async - */ - listEvaluationsAsync( - request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listEvaluations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listEvaluations.asyncIterate( - this.innerApiCalls['listEvaluations'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Location]{@link google.cloud.location.Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * [google.longrunning.Operation]{@link - * external:"google.longrunning.Operation"}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * [google.longrunning.Operation]{@link - * external:"google.longrunning.Operation"}. The promise has a method named - * "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified evaluation resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} processor - * @param {string} processor_version - * @param {string} evaluation - * @returns {string} Resource name string. - */ - evaluationPath(project:string,location:string,processor:string,processorVersion:string,evaluation:string) { - return this.pathTemplates.evaluationPathTemplate.render({ - project: project, - location: location, - processor: processor, - processor_version: processorVersion, - evaluation: evaluation, - }); - } - - /** - * Parse the project from Evaluation resource. - * - * @param {string} evaluationName - * A fully-qualified path representing Evaluation resource. - * @returns {string} A string representing the project. - */ - matchProjectFromEvaluationName(evaluationName: string) { - return this.pathTemplates.evaluationPathTemplate.match(evaluationName).project; - } - - /** - * Parse the location from Evaluation resource. - * - * @param {string} evaluationName - * A fully-qualified path representing Evaluation resource. - * @returns {string} A string representing the location. - */ - matchLocationFromEvaluationName(evaluationName: string) { - return this.pathTemplates.evaluationPathTemplate.match(evaluationName).location; - } - - /** - * Parse the processor from Evaluation resource. - * - * @param {string} evaluationName - * A fully-qualified path representing Evaluation resource. - * @returns {string} A string representing the processor. - */ - matchProcessorFromEvaluationName(evaluationName: string) { - return this.pathTemplates.evaluationPathTemplate.match(evaluationName).processor; - } - - /** - * Parse the processor_version from Evaluation resource. - * - * @param {string} evaluationName - * A fully-qualified path representing Evaluation resource. - * @returns {string} A string representing the processor_version. - */ - matchProcessorVersionFromEvaluationName(evaluationName: string) { - return this.pathTemplates.evaluationPathTemplate.match(evaluationName).processor_version; - } - - /** - * Parse the evaluation from Evaluation resource. - * - * @param {string} evaluationName - * A fully-qualified path representing Evaluation resource. - * @returns {string} A string representing the evaluation. - */ - matchEvaluationFromEvaluationName(evaluationName: string) { - return this.pathTemplates.evaluationPathTemplate.match(evaluationName).evaluation; - } - - /** - * 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 processorVersion resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} processor - * @param {string} processor_version - * @returns {string} Resource name string. - */ - processorVersionPath(project:string,location:string,processor:string,processorVersion:string) { - return this.pathTemplates.processorVersionPathTemplate.render({ - project: project, - location: location, - processor: processor, - processor_version: processorVersion, - }); - } - - /** - * Parse the project from ProcessorVersion resource. - * - * @param {string} processorVersionName - * A fully-qualified path representing ProcessorVersion resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProcessorVersionName(processorVersionName: string) { - return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).project; - } - - /** - * Parse the location from ProcessorVersion resource. - * - * @param {string} processorVersionName - * A fully-qualified path representing ProcessorVersion resource. - * @returns {string} A string representing the location. - */ - matchLocationFromProcessorVersionName(processorVersionName: string) { - return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).location; - } - - /** - * Parse the processor from ProcessorVersion resource. - * - * @param {string} processorVersionName - * A fully-qualified path representing ProcessorVersion resource. - * @returns {string} A string representing the processor. - */ - matchProcessorFromProcessorVersionName(processorVersionName: string) { - return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).processor; - } - - /** - * Parse the processor_version from ProcessorVersion resource. - * - * @param {string} processorVersionName - * A fully-qualified path representing ProcessorVersion resource. - * @returns {string} A string representing the processor_version. - */ - matchProcessorVersionFromProcessorVersionName(processorVersionName: string) { - return this.pathTemplates.processorVersionPathTemplate.match(processorVersionName).processor_version; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.documentProcessorServiceStub && !this._terminated) { - return this.documentProcessorServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client_config.json b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client_config.json deleted file mode 100644 index 2ed5da479a8..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_client_config.json +++ /dev/null @@ -1,113 +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" - }, - "ListProcessorTypes": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProcessors": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetProcessor": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TrainProcessorVersion": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetProcessorVersion": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListProcessorVersions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProcessorVersion": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeployProcessorVersion": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UndeployProcessorVersion": { - "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" - }, - "SetDefaultProcessorVersion": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ReviewDocument": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "EvaluateProcessorVersion": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetEvaluation": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListEvaluations": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_proto_list.json b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_proto_list.json deleted file mode 100644 index 673527d6d32..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/document_processor_service_proto_list.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - "../../protos/google/cloud/documentai/v1beta3/barcode.proto", - "../../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/document_schema.proto", - "../../protos/google/cloud/documentai/v1beta3/evaluation.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/google-cloud-documentai/v1beta3/src/v1beta3/gapic_metadata.json b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/gapic_metadata.json deleted file mode 100644 index 5252ce974c5..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/gapic_metadata.json +++ /dev/null @@ -1,249 +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" - ] - }, - "GetProcessor": { - "methods": [ - "getProcessor" - ] - }, - "GetProcessorVersion": { - "methods": [ - "getProcessorVersion" - ] - }, - "CreateProcessor": { - "methods": [ - "createProcessor" - ] - }, - "GetEvaluation": { - "methods": [ - "getEvaluation" - ] - }, - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - }, - "TrainProcessorVersion": { - "methods": [ - "trainProcessorVersion" - ] - }, - "DeleteProcessorVersion": { - "methods": [ - "deleteProcessorVersion" - ] - }, - "DeployProcessorVersion": { - "methods": [ - "deployProcessorVersion" - ] - }, - "UndeployProcessorVersion": { - "methods": [ - "undeployProcessorVersion" - ] - }, - "DeleteProcessor": { - "methods": [ - "deleteProcessor" - ] - }, - "EnableProcessor": { - "methods": [ - "enableProcessor" - ] - }, - "DisableProcessor": { - "methods": [ - "disableProcessor" - ] - }, - "SetDefaultProcessorVersion": { - "methods": [ - "setDefaultProcessorVersion" - ] - }, - "ReviewDocument": { - "methods": [ - "reviewDocument" - ] - }, - "EvaluateProcessorVersion": { - "methods": [ - "evaluateProcessorVersion" - ] - }, - "ListProcessorTypes": { - "methods": [ - "listProcessorTypes", - "listProcessorTypesStream", - "listProcessorTypesAsync" - ] - }, - "ListProcessors": { - "methods": [ - "listProcessors", - "listProcessorsStream", - "listProcessorsAsync" - ] - }, - "ListProcessorVersions": { - "methods": [ - "listProcessorVersions", - "listProcessorVersionsStream", - "listProcessorVersionsAsync" - ] - }, - "ListEvaluations": { - "methods": [ - "listEvaluations", - "listEvaluationsStream", - "listEvaluationsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DocumentProcessorServiceClient", - "rpcs": { - "ProcessDocument": { - "methods": [ - "processDocument" - ] - }, - "FetchProcessorTypes": { - "methods": [ - "fetchProcessorTypes" - ] - }, - "GetProcessor": { - "methods": [ - "getProcessor" - ] - }, - "GetProcessorVersion": { - "methods": [ - "getProcessorVersion" - ] - }, - "CreateProcessor": { - "methods": [ - "createProcessor" - ] - }, - "GetEvaluation": { - "methods": [ - "getEvaluation" - ] - }, - "BatchProcessDocuments": { - "methods": [ - "batchProcessDocuments" - ] - }, - "TrainProcessorVersion": { - "methods": [ - "trainProcessorVersion" - ] - }, - "DeleteProcessorVersion": { - "methods": [ - "deleteProcessorVersion" - ] - }, - "DeployProcessorVersion": { - "methods": [ - "deployProcessorVersion" - ] - }, - "UndeployProcessorVersion": { - "methods": [ - "undeployProcessorVersion" - ] - }, - "DeleteProcessor": { - "methods": [ - "deleteProcessor" - ] - }, - "EnableProcessor": { - "methods": [ - "enableProcessor" - ] - }, - "DisableProcessor": { - "methods": [ - "disableProcessor" - ] - }, - "SetDefaultProcessorVersion": { - "methods": [ - "setDefaultProcessorVersion" - ] - }, - "ReviewDocument": { - "methods": [ - "reviewDocument" - ] - }, - "EvaluateProcessorVersion": { - "methods": [ - "evaluateProcessorVersion" - ] - }, - "ListProcessorTypes": { - "methods": [ - "listProcessorTypes", - "listProcessorTypesStream", - "listProcessorTypesAsync" - ] - }, - "ListProcessors": { - "methods": [ - "listProcessors", - "listProcessorsStream", - "listProcessorsAsync" - ] - }, - "ListProcessorVersions": { - "methods": [ - "listProcessorVersions", - "listProcessorVersionsStream", - "listProcessorVersionsAsync" - ] - }, - "ListEvaluations": { - "methods": [ - "listEvaluations", - "listEvaluationsStream", - "listEvaluationsAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/index.ts deleted file mode 100644 index db3b76d115a..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/src/v1beta3/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {DocumentProcessorServiceClient} from './document_processor_service_client'; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 27e40317e22..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const documentai = require('@google-cloud/documentai'); - -function main() { - const documentProcessorServiceClient = new documentai.DocumentProcessorServiceClient(); -} - -main(); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index b1548f79d2e..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {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/google-cloud-documentai/v1beta3/system-test/install.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/install.ts deleted file mode 100644 index 557a57558e1..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/test/gapic_document_processor_service_v1beta3.ts b/owl-bot-staging/google-cloud-documentai/v1beta3/test/gapic_document_processor_service_v1beta3.ts deleted file mode 100644 index 8a55588da63..00000000000 --- a/owl-bot-staging/google-cloud-documentai/v1beta3/test/gapic_document_processor_service_v1beta3.ts +++ /dev/null @@ -1,4281 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; -import * as documentprocessorserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1beta3.DocumentProcessorServiceClient', () => { - describe('Common methods', () => { - 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 for the initialized client', done => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.documentProcessorServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.documentProcessorServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.processDocument = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.processDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.processDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes processDocument with closed client', 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ProcessRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.processDocument(request), expectedError); - }); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.fetchProcessorTypes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchProcessorTypes(request), expectedError); - const actualRequest = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.fetchProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes fetchProcessorTypes with closed client', 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.FetchProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.fetchProcessorTypes(request), expectedError); - }); - }); - - describe('getProcessor', () => { - it('invokes getProcessor 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.GetProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.Processor() - ); - client.innerApiCalls.getProcessor = stubSimpleCall(expectedResponse); - const [response] = await client.getProcessor(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessor 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.GetProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.Processor() - ); - client.innerApiCalls.getProcessor = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProcessor( - 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); - const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessor 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.GetProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProcessor = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProcessor(request), expectedError); - const actualRequest = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessor with closed client', 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.GetProcessorRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProcessor(request), expectedError); - }); - }); - - describe('getProcessorVersion', () => { - it('invokes getProcessorVersion 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.GetProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() - ); - client.innerApiCalls.getProcessorVersion = stubSimpleCall(expectedResponse); - const [response] = await client.getProcessorVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessorVersion 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.GetProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() - ); - client.innerApiCalls.getProcessorVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProcessorVersion( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessorVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessorVersion 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.GetProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProcessorVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProcessorVersion with closed client', 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.GetProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProcessorVersion(request), expectedError); - }); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.CreateProcessorRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.CreateProcessorRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.CreateProcessorRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProcessor = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProcessor(request), expectedError); - const actualRequest = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProcessor with closed client', 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.CreateProcessorRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProcessor(request), expectedError); - }); - }); - - describe('getEvaluation', () => { - it('invokes getEvaluation 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.GetEvaluationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetEvaluationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.Evaluation() - ); - client.innerApiCalls.getEvaluation = stubSimpleCall(expectedResponse); - const [response] = await client.getEvaluation(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEvaluation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEvaluation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEvaluation 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.GetEvaluationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetEvaluationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.Evaluation() - ); - client.innerApiCalls.getEvaluation = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEvaluation( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IEvaluation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEvaluation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEvaluation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEvaluation 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.GetEvaluationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetEvaluationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEvaluation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEvaluation(request), expectedError); - const actualRequest = (client.innerApiCalls.getEvaluation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEvaluation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEvaluation with closed client', 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.GetEvaluationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.GetEvaluationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getEvaluation(request), expectedError); - }); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.BatchProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.BatchProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.BatchProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchProcessDocuments(request), expectedError); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.BatchProcessRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchProcessDocuments = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchProcessDocuments(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchProcessDocuments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('trainProcessorVersion', () => { - it('invokes trainProcessorVersion 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.TrainProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.trainProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.trainProcessorVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.trainProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.trainProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes trainProcessorVersion 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.TrainProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.trainProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.trainProcessorVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.trainProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.trainProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes trainProcessorVersion 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.TrainProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.trainProcessorVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.trainProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.trainProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.trainProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes trainProcessorVersion 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.TrainProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.trainProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.trainProcessorVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.trainProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.trainProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkTrainProcessorVersionProgress 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.checkTrainProcessorVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkTrainProcessorVersionProgress 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.checkTrainProcessorVersionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteProcessorVersion', () => { - it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteProcessorVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProcessorVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProcessorVersion 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.DeleteProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteProcessorVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteProcessorVersionProgress 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.checkDeleteProcessorVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteProcessorVersionProgress 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.checkDeleteProcessorVersionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deployProcessorVersion', () => { - it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.deployProcessorVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deployProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deployProcessorVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deployProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deployProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deployProcessorVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeployProcessorVersionProgress 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.checkDeployProcessorVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeployProcessorVersionProgress 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.checkDeployProcessorVersionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('undeployProcessorVersion', () => { - it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.undeployProcessorVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeployProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.undeployProcessorVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.undeployProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeployProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.undeployProcessorVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeployProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUndeployProcessorVersionProgress 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.checkUndeployProcessorVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUndeployProcessorVersionProgress 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.checkUndeployProcessorVersionProgress(''), 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteProcessor(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DeleteProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessor = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteProcessor(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.EnableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.EnableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.EnableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.enableProcessor(request), expectedError); - const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.EnableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.enableProcessor = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.enableProcessor(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.enableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DisableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DisableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DisableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.disableProcessor(request), expectedError); - const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.DisableProcessorRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.disableProcessor = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.disableProcessor(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.disableProcessor as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('setDefaultProcessorVersion', () => { - it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionRequest', ['processor']); - request.processor = defaultValue1; - const expectedHeaderRequestParams = `processor=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.setDefaultProcessorVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionRequest', ['processor']); - request.processor = defaultValue1; - const expectedHeaderRequestParams = `processor=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setDefaultProcessorVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionRequest', ['processor']); - request.processor = defaultValue1; - const expectedHeaderRequestParams = `processor=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setDefaultProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setDefaultProcessorVersion 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.SetDefaultProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.SetDefaultProcessorVersionRequest', ['processor']); - request.processor = defaultValue1; - const expectedHeaderRequestParams = `processor=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setDefaultProcessorVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkSetDefaultProcessorVersionProgress 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.checkSetDefaultProcessorVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkSetDefaultProcessorVersionProgress 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.checkSetDefaultProcessorVersionProgress(''), 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ReviewDocumentRequest', ['humanReviewConfig']); - request.humanReviewConfig = defaultValue1; - const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ReviewDocumentRequest', ['humanReviewConfig']); - request.humanReviewConfig = defaultValue1; - const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ReviewDocumentRequest', ['humanReviewConfig']); - request.humanReviewConfig = defaultValue1; - const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reviewDocument(request), expectedError); - const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ReviewDocumentRequest', ['humanReviewConfig']); - request.humanReviewConfig = defaultValue1; - const expectedHeaderRequestParams = `human_review_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.reviewDocument = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reviewDocument(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reviewDocument as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('evaluateProcessorVersion', () => { - it('invokes evaluateProcessorVersion 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.EvaluateProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', ['processorVersion']); - request.processorVersion = defaultValue1; - const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.evaluateProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.evaluateProcessorVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes evaluateProcessorVersion 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.EvaluateProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', ['processorVersion']); - request.processorVersion = defaultValue1; - const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.evaluateProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.evaluateProcessorVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes evaluateProcessorVersion 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.EvaluateProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', ['processorVersion']); - request.processorVersion = defaultValue1; - const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.evaluateProcessorVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.evaluateProcessorVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes evaluateProcessorVersion 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.EvaluateProcessorVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', ['processorVersion']); - request.processorVersion = defaultValue1; - const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.evaluateProcessorVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.evaluateProcessorVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.evaluateProcessorVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkEvaluateProcessorVersionProgress 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.checkEvaluateProcessorVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkEvaluateProcessorVersionProgress 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.checkEvaluateProcessorVersionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProcessorTypes', () => { - it('invokes listProcessorTypes 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - ]; - client.innerApiCalls.listProcessorTypes = stubSimpleCall(expectedResponse); - const [response] = await client.listProcessorTypes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorTypes 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - ]; - client.innerApiCalls.listProcessorTypes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProcessorTypes( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessorType[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorTypes 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProcessorTypes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProcessorTypes(request), expectedError); - const actualRequest = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorTypes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorTypesStream 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - ]; - client.descriptors.page.listProcessorTypes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProcessorTypesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.ProcessorType[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1beta3.ProcessorType) => { - 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.listProcessorTypes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProcessorTypes, request)); - assert( - (client.descriptors.page.listProcessorTypes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProcessorTypesStream 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProcessorTypes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProcessorTypesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.ProcessorType[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1beta3.ProcessorType) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProcessorTypes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProcessorTypes, request)); - assert( - (client.descriptors.page.listProcessorTypes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProcessorTypes 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorType()), - ]; - client.descriptors.page.listProcessorTypes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.documentai.v1beta3.IProcessorType[] = []; - const iterable = client.listProcessorTypesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProcessorTypes 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.ListProcessorTypesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProcessorTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProcessorTypesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.documentai.v1beta3.IProcessorType[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProcessorTypes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProcessors = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProcessors(request), expectedError); - const actualRequest = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessors as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listProcessors.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listProcessors.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listProcessors.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listProcessors.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProcessorVersions', () => { - it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - ]; - client.innerApiCalls.listProcessorVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listProcessorVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - ]; - client.innerApiCalls.listProcessorVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProcessorVersions( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IProcessorVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProcessorVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProcessorVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProcessorVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProcessorVersionsStream 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - ]; - client.descriptors.page.listProcessorVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProcessorVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.ProcessorVersion[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1beta3.ProcessorVersion) => { - 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.listProcessorVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProcessorVersions, request)); - assert( - (client.descriptors.page.listProcessorVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProcessorVersionsStream 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProcessorVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProcessorVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.ProcessorVersion[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1beta3.ProcessorVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProcessorVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProcessorVersions, request)); - assert( - (client.descriptors.page.listProcessorVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProcessorVersions 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.ProcessorVersion()), - ]; - client.descriptors.page.listProcessorVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.documentai.v1beta3.IProcessorVersion[] = []; - const iterable = client.listProcessorVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProcessorVersions 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.ListProcessorVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProcessorVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProcessorVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.documentai.v1beta3.IProcessorVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProcessorVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listEvaluations', () => { - it('invokes listEvaluations 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.ListEvaluationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - ]; - client.innerApiCalls.listEvaluations = stubSimpleCall(expectedResponse); - const [response] = await client.listEvaluations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEvaluations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEvaluations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEvaluations 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.ListEvaluationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - ]; - client.innerApiCalls.listEvaluations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEvaluations( - request, - (err?: Error|null, result?: protos.google.cloud.documentai.v1beta3.IEvaluation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEvaluations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEvaluations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEvaluations 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.ListEvaluationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEvaluations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEvaluations(request), expectedError); - const actualRequest = (client.innerApiCalls.listEvaluations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEvaluations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEvaluationsStream 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.ListEvaluationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - ]; - client.descriptors.page.listEvaluations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEvaluationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.Evaluation[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1beta3.Evaluation) => { - 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.listEvaluations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEvaluations, request)); - assert( - (client.descriptors.page.listEvaluations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listEvaluationsStream 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.ListEvaluationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listEvaluations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEvaluationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.Evaluation[] = []; - stream.on('data', (response: protos.google.cloud.documentai.v1beta3.Evaluation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEvaluations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEvaluations, request)); - assert( - (client.descriptors.page.listEvaluations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEvaluations 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.ListEvaluationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - generateSampleMessage(new protos.google.cloud.documentai.v1beta3.Evaluation()), - ]; - client.descriptors.page.listEvaluations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.documentai.v1beta3.IEvaluation[] = []; - const iterable = client.listEvaluationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEvaluations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEvaluations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEvaluations 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.ListEvaluationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listEvaluations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEvaluationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.documentai.v1beta3.IEvaluation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEvaluations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEvaluations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('evaluation', () => { - const fakePath = "/rendered/path/evaluation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - processor: "processorValue", - processor_version: "processorVersionValue", - evaluation: "evaluationValue", - }; - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.evaluationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.evaluationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('evaluationPath', () => { - const result = client.evaluationPath("projectValue", "locationValue", "processorValue", "processorVersionValue", "evaluationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.evaluationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEvaluationName', () => { - const result = client.matchProjectFromEvaluationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.evaluationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEvaluationName', () => { - const result = client.matchLocationFromEvaluationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.evaluationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorFromEvaluationName', () => { - const result = client.matchProcessorFromEvaluationName(fakePath); - assert.strictEqual(result, "processorValue"); - assert((client.pathTemplates.evaluationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorVersionFromEvaluationName', () => { - const result = client.matchProcessorVersionFromEvaluationName(fakePath); - assert.strictEqual(result, "processorVersionValue"); - assert((client.pathTemplates.evaluationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEvaluationFromEvaluationName', () => { - const result = client.matchEvaluationFromEvaluationName(fakePath); - assert.strictEqual(result, "evaluationValue"); - assert((client.pathTemplates.evaluationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - 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('processorVersion', () => { - const fakePath = "/rendered/path/processorVersion"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - processor: "processorValue", - processor_version: "processorVersionValue", - }; - const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.processorVersionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.processorVersionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('processorVersionPath', () => { - const result = client.processorVersionPath("projectValue", "locationValue", "processorValue", "processorVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.processorVersionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProcessorVersionName', () => { - const result = client.matchProjectFromProcessorVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProcessorVersionName', () => { - const result = client.matchLocationFromProcessorVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorFromProcessorVersionName', () => { - const result = client.matchProcessorFromProcessorVersionName(fakePath); - assert.strictEqual(result, "processorValue"); - assert((client.pathTemplates.processorVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProcessorVersionFromProcessorVersionName', () => { - const result = client.matchProcessorVersionFromProcessorVersionName(fakePath); - assert.strictEqual(result, "processorVersionValue"); - assert((client.pathTemplates.processorVersionPathTemplate.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/google-cloud-documentai/v1beta3/tsconfig.json b/owl-bot-staging/google-cloud-documentai/v1beta3/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/google-cloud-documentai/v1beta3/webpack.config.js b/owl-bot-staging/google-cloud-documentai/v1beta3/webpack.config.js deleted file mode 100644 index fc7bef574e6..00000000000 --- a/owl-bot-staging/google-cloud-documentai/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/packages/google-cloud-documentai/README.md b/packages/google-cloud-documentai/README.md index 58ebf7d8167..cf6211fa336 100644 --- a/packages/google-cloud-documentai/README.md +++ b/packages/google-cloud-documentai/README.md @@ -162,15 +162,19 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/ | Document_processor_service.deploy_processor_version | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.deploy_processor_version.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.deploy_processor_version.js,samples/README.md) | | Document_processor_service.disable_processor | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.disable_processor.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.disable_processor.js,samples/README.md) | | Document_processor_service.enable_processor | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.enable_processor.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.enable_processor.js,samples/README.md) | +| Document_processor_service.evaluate_processor_version | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js,samples/README.md) | | Document_processor_service.fetch_processor_types | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js,samples/README.md) | +| Document_processor_service.get_evaluation | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_evaluation.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_evaluation.js,samples/README.md) | | Document_processor_service.get_processor | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor.js,samples/README.md) | | Document_processor_service.get_processor_version | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor_version.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor_version.js,samples/README.md) | +| Document_processor_service.list_evaluations | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_evaluations.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_evaluations.js,samples/README.md) | | Document_processor_service.list_processor_types | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processor_types.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processor_types.js,samples/README.md) | | Document_processor_service.list_processor_versions | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processor_versions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processor_versions.js,samples/README.md) | | Document_processor_service.list_processors | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processors.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processors.js,samples/README.md) | | Document_processor_service.process_document | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.process_document.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.process_document.js,samples/README.md) | | Document_processor_service.review_document | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.review_document.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.review_document.js,samples/README.md) | | Document_processor_service.set_default_processor_version | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.set_default_processor_version.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.set_default_processor_version.js,samples/README.md) | +| Document_processor_service.train_processor_version | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.train_processor_version.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.train_processor_version.js,samples/README.md) | | Document_processor_service.undeploy_processor_version | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js,samples/README.md) | | Quickstart | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/quickstart.js,samples/README.md) | | Quickstart.test | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/test/quickstart.test.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/test/quickstart.test.js,samples/README.md) | diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/barcode.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/barcode.proto index 7c7050a868b..9b063faf287 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/barcode.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/barcode.proto @@ -28,40 +28,42 @@ option ruby_package = "Google::Cloud::DocumentAI::V1beta3"; message Barcode { // Format of a barcode. // The supported formats are: - // CODE_128: Code 128 type. - // CODE_39: Code 39 type. - // CODE_93: Code 93 type. - // CODABAR: Codabar type. - // DATA_MATRIX: 2D Data Matrix type. - // ITF: ITF type. - // EAN_13: EAN-13 type. - // EAN_8: EAN-8 type. - // QR_CODE: 2D QR code type. - // UPC_A: UPC-A type. - // UPC_E: UPC-E type. - // PDF417: PDF417 type. - // AZTEC: 2D Aztec code type. - // DATABAR: GS1 DataBar code type. + // + // - `CODE_128`: Code 128 type. + // - `CODE_39`: Code 39 type. + // - `CODE_93`: Code 93 type. + // - `CODABAR`: Codabar type. + // - `DATA_MATRIX`: 2D Data Matrix type. + // - `ITF`: ITF type. + // - `EAN_13`: EAN-13 type. + // - `EAN_8`: EAN-8 type. + // - `QR_CODE`: 2D QR code type. + // - `UPC_A`: UPC-A type. + // - `UPC_E`: UPC-E type. + // - `PDF417`: PDF417 type. + // - `AZTEC`: 2D Aztec code type. + // - `DATABAR`: GS1 DataBar code type. string format = 1; // Value format describes the format of the value that a barcode // encodes. // The supported formats are: - // CONTACT_INFO: Contact information. - // EMAIL: Email address. - // ISBN: ISBN identifier. - // PHONE: Phone number. - // PRODUCT: Product. - // SMS: SMS message. - // TEXT: Text string. - // URL: URL address. - // WIFI: Wifi information. - // GEO: Geo-localization. - // CALENDAR_EVENT: Calendar event. - // DRIVER_LICENSE: Driver's license. + // + // - `CONTACT_INFO`: Contact information. + // - `EMAIL`: Email address. + // - `ISBN`: ISBN identifier. + // - `PHONE`: Phone number. + // - `PRODUCT`: Product. + // - `SMS`: SMS message. + // - `TEXT`: Text string. + // - `URL`: URL address. + // - `WIFI`: Wifi information. + // - `GEO`: Geo-localization. + // - `CALENDAR_EVENT`: Calendar event. + // - `DRIVER_LICENSE`: Driver's license. string value_format = 2; // Raw value encoded in the barcode. - // For example, 'MEBKM:TITLE:Google;URL:https://www.google.com;;'. + // For example: `'MEBKM:TITLE:Google;URL:https://www.google.com;;'`. string raw_value = 3; } diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document.proto index 809a64ea4c7..2ae46db8e24 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document.proto @@ -91,6 +91,10 @@ message Document { // Font size. FontSize font_size = 7; + + // Font family such as `Arial`, `Times New Roman`. + // https://www.w3schools.com/cssref/pr_font_font-family.asp + string font_family = 8; } // A page in a [Document][google.cloud.documentai.v1beta3.Document]. @@ -169,7 +173,7 @@ message Document { // 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]. + // 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]. @@ -189,7 +193,7 @@ message Document { repeated DetectedLanguage detected_languages = 2; // The history of this annotation. - Provenance provenance = 3; + Provenance provenance = 3 [deprecated = true]; } // A collection of lines that a human would perceive as a paragraph. @@ -201,7 +205,7 @@ message Document { repeated DetectedLanguage detected_languages = 2; // The history of this annotation. - Provenance provenance = 3; + Provenance provenance = 3 [deprecated = true]; } // A collection of tokens that a human would perceive as a line. @@ -214,7 +218,7 @@ message Document { repeated DetectedLanguage detected_languages = 2; // The history of this annotation. - Provenance provenance = 3; + Provenance provenance = 3 [deprecated = true]; } // A detected token. @@ -249,8 +253,8 @@ message Document { // A list of detected languages together with confidence. repeated DetectedLanguage detected_languages = 3; - // The history of this annotation. - Provenance provenance = 4; + // The history of this annotation. + Provenance provenance = 4 [deprecated = true]; } // A detected symbol. @@ -309,6 +313,9 @@ message Document { // A list of detected languages together with confidence. repeated DetectedLanguage detected_languages = 4; + + // The history of this table. + Provenance provenance = 5; } // A form field detected on the page. @@ -358,15 +365,43 @@ message Document { // Detected language for a structural component. message DetectedLanguage { - // The BCP-47 language code, such as "en-US" or "sr-Latn". For more + // The BCP-47 language code, such as `en-US` or `sr-Latn`. For more // information, see // https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. string language_code = 1; - // Confidence of detected language. Range [0, 1]. + // Confidence of detected language. Range `[0, 1]`. float confidence = 2; } + // Image Quality Scores for the page image + message ImageQualityScores { + // Image Quality Defects + message DetectedDefect { + // Name of the defect type. Supported values are: + // + // - `quality/defect_blurry` + // - `quality/defect_noisy` + // - `quality/defect_dark` + // - `quality/defect_faint` + // - `quality/defect_text_too_small` + // - `quality/defect_document_cutoff` + // - `quality/defect_text_cutoff` + // - `quality/defect_glare` + string type = 1; + + // Confidence of detected defect. Range `[0, 1]` where 1 indicates + // strong confidence of that the defect exists. + float confidence = 2; + } + + // The overall quality score. Range `[0, 1]` where 1 is perfect quality. + float quality_score = 1; + + // A list of detected defects. + repeated DetectedDefect detected_defects = 2; + } + // 1-based index for current [Page][google.cloud.documentai.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. @@ -422,8 +457,11 @@ message Document { // A list of detected barcodes. repeated DetectedBarcode detected_barcodes = 15; + // Image Quality Scores. + ImageQualityScores image_quality_scores = 17; + // The history of this page. - Provenance provenance = 16; + Provenance provenance = 16 [deprecated = true]; } // An entity that could be a phrase in the text or a property that belongs to @@ -471,6 +509,7 @@ message Document { // or int normalized text by default. // // Below are sample formats mapped to structured values. + // // - Money/Currency type (`money_value`) is in the ISO 4217 text format. // - Date type (`date_value`) is in the ISO 8601 text format. // - Datetime type (`datetime_value`) is in the ISO 8601 text format. @@ -484,14 +523,13 @@ message Document { // Required. Entity type from a schema e.g. `Address`. string type = 2 [(google.api.field_behavior) = REQUIRED]; - // Optional. Text value in the document e.g. `1600 Amphitheatre Pkwy`. If the entity - // is not present in the document, this field will be empty. + // Optional. Text value of the entity e.g. `1600 Amphitheatre Pkwy`. string mention_text = 3 [(google.api.field_behavior) = OPTIONAL]; // Optional. Deprecated. Use `id` field instead. string mention_id = 4 [(google.api.field_behavior) = OPTIONAL]; - // Optional. Confidence of detected Schema entity. Range [0, 1]. + // 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 @@ -605,7 +643,7 @@ message Document { // 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]. + // Optional. Confidence of detected page element, if applicable. Range `[0, 1]`. float confidence = 5 [(google.api.field_behavior) = OPTIONAL]; } @@ -726,7 +764,7 @@ message Document { string changed_text = 2; // The history of this annotation. - repeated Provenance provenance = 3; + repeated Provenance provenance = 3 [deprecated = true]; } // Original source document from the user. @@ -765,9 +803,9 @@ message Document { // Placeholder. Relationship among [Document.entities][google.cloud.documentai.v1beta3.Document.entities]. repeated EntityRelation entity_relations = 8; - // Placeholder. 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. + // Placeholder. A list of text corrections made to [Document.text][google.cloud.documentai.v1beta3.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 diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_io.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_io.proto index a0d410c8cb4..e41458e0a24 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_io.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_io.proto @@ -16,6 +16,8 @@ syntax = "proto3"; package google.cloud.documentai.v1beta3; +import "google/protobuf/field_mask.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; @@ -30,7 +32,7 @@ message RawDocument { bytes content = 1; // An IANA MIME type (RFC6838) indicating the nature and format of the - // [content]. + // [content][google.cloud.documentai.v1beta3.RawDocument.content]. string mime_type = 2; } @@ -59,7 +61,7 @@ message GcsPrefix { message BatchDocumentsInputConfig { // The source. oneof source { - // The set of documents that match the specified Cloud Storage [gcs_prefix]. + // 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. @@ -74,6 +76,11 @@ message DocumentOutputConfig { message GcsOutputConfig { // The Cloud Storage uri (a directory) of the output. string gcs_uri = 1; + + // Specifies which fields to include in the output documents. + // Only supports top level document and pages field so it must be in the + // form of `{document_field_name}` or `pages.{page_field_name}`. + google.protobuf.FieldMask field_mask = 2; } // The destination of the results. diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_processor_service.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_processor_service.proto index 952db5904d5..34e3380413b 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_processor_service.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_processor_service.proto @@ -23,6 +23,7 @@ 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/document_schema.proto"; +import "google/cloud/documentai/v1beta3/evaluation.proto"; import "google/cloud/documentai/v1beta3/operation_metadata.proto"; import "google/cloud/documentai/v1beta3/processor.proto"; import "google/cloud/documentai/v1beta3/processor_type.proto"; @@ -119,6 +120,21 @@ service DocumentProcessorService { option (google.api.method_signature) = "name"; } + // Trains a new processor version. + // Operation metadata is returned as + // cloud_documentai_core.TrainProcessorVersionMetadata. + rpc TrainProcessorVersion(TrainProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta3/{parent=projects/*/locations/*/processors/*}/processorVersions:train" + body: "*" + }; + option (google.api.method_signature) = "parent,processor_version"; + option (google.longrunning.operation_info) = { + response_type: "TrainProcessorVersionResponse" + metadata_type: "TrainProcessorVersionMetadata" + }; + } + // Gets a processor version detail. rpc GetProcessorVersion(GetProcessorVersionRequest) returns (ProcessorVersion) { option (google.api.http) = { @@ -248,6 +264,36 @@ service DocumentProcessorService { metadata_type: "ReviewDocumentOperationMetadata" }; } + + // Evaluates a ProcessorVersion against annotated documents, producing an + // Evaluation. + rpc EvaluateProcessorVersion(EvaluateProcessorVersionRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1beta3/{processor_version=projects/*/locations/*/processors/*/processorVersions/*}:evaluateProcessorVersion" + body: "*" + }; + option (google.api.method_signature) = "processor_version"; + option (google.longrunning.operation_info) = { + response_type: "EvaluateProcessorVersionResponse" + metadata_type: "EvaluateProcessorVersionMetadata" + }; + } + + // Retrieves a specific evaluation. + rpc GetEvaluation(GetEvaluationRequest) returns (Evaluation) { + option (google.api.http) = { + get: "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*/evaluations/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Retrieves a set of evaluations for a given processor version. + rpc ListEvaluations(ListEvaluationsRequest) returns (ListEvaluationsResponse) { + option (google.api.http) = { + get: "/v1beta3/{parent=projects/*/locations/*/processors/*/processorVersions/*}/evaluations" + }; + option (google.api.method_signature) = "parent"; + } } // Request message for the process document method. @@ -282,6 +328,8 @@ message ProcessRequest { bool skip_human_review = 3; // Specifies which fields to include in ProcessResponse's document. + // Only supports top level document and pages field so it must be in the form + // of `{document_field_name}` or `pages.{page_field_name}`. google.protobuf.FieldMask field_mask = 6; } @@ -769,6 +817,79 @@ message SetDefaultProcessorVersionMetadata { CommonOperationMetadata common_metadata = 1; } +// Request message for the create processor version method. +message TrainProcessorVersionRequest { + // The input data used to train a new `ProcessorVersion`. + message InputData { + // The documents used for training the new version. + BatchDocumentsInputConfig training_documents = 3; + + // The documents used for testing the trained version. + BatchDocumentsInputConfig test_documents = 4; + } + + // Required. The parent (project, location and processor) to create the new version for. + // Format: `projects/{project}/locations/{location}/processors/{processor}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "documentai.googleapis.com/ProcessorVersion" + } + ]; + + // Required. The processor version to be created. + ProcessorVersion processor_version = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The schema the processor version will be trained with. + DocumentSchema document_schema = 10 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The input data used to train the `ProcessorVersion`. + InputData input_data = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The processor version to use as a base for training. This processor version + // must be a child of `parent`. Format: + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`. + string base_processor_version = 8 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for the TrainProcessorVersion method. +message TrainProcessorVersionResponse { + // The resource name of the processor version produced by training. + string processor_version = 1; +} + +// The metadata that represents a processor version being created. +message TrainProcessorVersionMetadata { + // The dataset validation information. + // This includes any and all errors with documents and the dataset. + message DatasetValidation { + // The total number of document errors. + int32 document_error_count = 3; + + // The total number of dataset errors. + int32 dataset_error_count = 4; + + // Error information pertaining to specific documents. A maximum of 10 + // document errors will be returned. + // Any document with errors will not be used throughout training. + repeated google.rpc.Status document_errors = 1; + + // Error information for the dataset as a whole. A maximum of 10 dataset + // errors will be returned. + // A single dataset error is terminal for training. + repeated google.rpc.Status dataset_errors = 2; + } + + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; + + // The training dataset validation information. + DatasetValidation training_dataset_validation = 2; + + // The test dataset validation information. + DatasetValidation test_dataset_validation = 3; +} + // Request message for review document method. message ReviewDocumentRequest { // The priority level of the human review task. @@ -876,3 +997,74 @@ message ReviewDocumentOperationMetadata { // The Crowd Compute question ID. string question_id = 6; } + +// Evaluates the given ProcessorVersion against the supplied documents. +message EvaluateProcessorVersionRequest { + // Required. The resource name of the [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion] to evaluate. + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + string processor_version = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; + + // Optional. The documents used in the evaluation. If unspecified, use the processor's + // dataset as evaluation input. + BatchDocumentsInputConfig evaluation_documents = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Metadata of the EvaluateProcessorVersion method. +message EvaluateProcessorVersionMetadata { + // The basic metadata of the long running operation. + CommonOperationMetadata common_metadata = 1; +} + +// Metadata of the EvaluateProcessorVersion method. +message EvaluateProcessorVersionResponse { + // The resource name of the created evaluation. + string evaluation = 2; +} + +// Retrieves a specific Evaluation. +message GetEvaluationRequest { + // Required. The resource name of the [Evaluation][google.cloud.documentai.v1beta3.Evaluation] to get. + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/Evaluation" + } + ]; +} + +// Retrieves a list of evaluations for a given ProcessorVersion. +message ListEvaluationsRequest { + // Required. The resource name of the [ProcessorVersion][google.cloud.documentai.v1beta3.ProcessorVersion] to list evaluations for. + // `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "documentai.googleapis.com/ProcessorVersion" + } + ]; + + // The standard list page size. + // If unspecified, at most 5 evaluations will be returned. + // The maximum value is 100; values above 100 will be coerced to 100. + int32 page_size = 2; + + // A page token, received from a previous `ListEvaluations` call. + // Provide this to retrieve the subsequent page. + string page_token = 3; +} + +// The response from ListEvaluations. +message ListEvaluationsResponse { + // The evaluations requested. + repeated Evaluation evaluations = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_schema.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_schema.proto index 214e56864de..1e29f7c89d9 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_schema.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document_schema.proto @@ -86,15 +86,16 @@ message DocumentSchema { // Name of the type. It must be unique within the schema file and // cannot be a 'Common Type'. Besides that we use the following naming // conventions: - // - *use snake_casing* + // + // - *use `snake_casing`* // - name matching is case-insensitive // - Maximum 64 characters. // - Must start with a letter. // - Allowed characters: ASCII letters `[a-z0-9_-]`. (For backward // compatibility internal infrastructure and tooling can handle any ascii // character) - // - The '/' is sometimes used to denote a property of a type. For example - // line_item/amount. This convention is deprecated, but will still be + // - The `/` is sometimes used to denote a property of a type. For example + // `line_item/amount`. This convention is deprecated, but will still be // honored for backward compatibility. string name = 1; diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/evaluation.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/evaluation.proto similarity index 100% rename from owl-bot-staging/google-cloud-documentai/v1beta3/protos/google/cloud/documentai/v1beta3/evaluation.proto rename to packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/evaluation.proto diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/processor.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/processor.proto index b7019bf4d12..db13e89defa 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/processor.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/processor.proto @@ -18,6 +18,7 @@ package google.cloud.documentai.v1beta3; import "google/api/field_behavior.proto"; import "google/api/resource.proto"; +import "google/cloud/documentai/v1beta3/document_schema.proto"; import "google/protobuf/timestamp.proto"; option csharp_namespace = "Google.Cloud.DocumentAI.V1Beta3"; @@ -85,6 +86,9 @@ message ProcessorVersion { // The display name of the processor version. string display_name = 2; + // The schema of the processor version. Describes the output. + DocumentSchema document_schema = 12; + // The state of the processor version. State state = 6; @@ -125,14 +129,14 @@ message Processor { // The processor is disabled. DISABLED = 2; - // The processor is being enabled, will become ENABLED if successful. + // The processor is being enabled, will become `ENABLED` if successful. ENABLING = 3; - // The processor is being disabled, will become DISABLED if successful. + // The processor is being disabled, will become `DISABLED` if successful. DISABLING = 4; - // The processor is being created, will become either ENABLED (for - // successful creation) or FAILED (for failed ones). + // The processor is being created, will become either `ENABLED` (for + // successful creation) or `FAILED` (for failed ones). // Once a processor is in this state, it can then be used for document // processing, but the feature dependencies of the processor might not be // fully created yet. @@ -154,7 +158,7 @@ message Processor { (google.api.field_behavior) = OUTPUT_ONLY ]; - // The processor type, e.g., OCR_PROCESSOR, INVOICE_PROCESSOR, etc. + // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. // To get a list of processors types, see // [FetchProcessorTypes][google.cloud.documentai.v1beta3.DocumentProcessorService.FetchProcessorTypes]. string type = 2; diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/processor_type.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/processor_type.proto index a2799e301a9..9afbf04d481 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/processor_type.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/processor_type.proto @@ -42,10 +42,10 @@ message ProcessorType { } // The resource name of the processor type. - // Format: projects/{project}/processorTypes/{processor_type} + // Format: `projects/{project}/processorTypes/{processor_type}` string name = 1; - // The type of the processor, e.g., "invoice_parsing". + // The processor type, e.g., `OCR_PROCESSOR`, `INVOICE_PROCESSOR`, etc. string type = 2; // The processor category, used by UI to group processor types. diff --git a/packages/google-cloud-documentai/protos/protos.d.ts b/packages/google-cloud-documentai/protos/protos.d.ts index af6c5eac483..4c85bb63f92 100644 --- a/packages/google-cloud-documentai/protos/protos.d.ts +++ b/packages/google-cloud-documentai/protos/protos.d.ts @@ -21168,6 +21168,9 @@ export namespace google { /** Style fontSize */ fontSize?: (google.cloud.documentai.v1beta3.Document.Style.IFontSize|null); + + /** Style fontFamily */ + fontFamily?: (string|null); } /** Represents a Style. */ @@ -21200,6 +21203,9 @@ export namespace google { /** Style fontSize. */ public fontSize?: (google.cloud.documentai.v1beta3.Document.Style.IFontSize|null); + /** Style fontFamily. */ + public fontFamily: string; + /** * Creates a new Style instance using the specified properties. * @param [properties] Properties to set @@ -21432,6 +21438,9 @@ export namespace google { /** Page detectedBarcodes */ detectedBarcodes?: (google.cloud.documentai.v1beta3.Document.Page.IDetectedBarcode[]|null); + /** Page imageQualityScores */ + imageQualityScores?: (google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores|null); + /** Page provenance */ provenance?: (google.cloud.documentai.v1beta3.Document.IProvenance|null); } @@ -21490,6 +21499,9 @@ export namespace google { /** Page detectedBarcodes. */ public detectedBarcodes: google.cloud.documentai.v1beta3.Document.Page.IDetectedBarcode[]; + /** Page imageQualityScores. */ + public imageQualityScores?: (google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores|null); + /** Page provenance. */ public provenance?: (google.cloud.documentai.v1beta3.Document.IProvenance|null); @@ -22818,6 +22830,9 @@ export namespace google { /** Table detectedLanguages */ detectedLanguages?: (google.cloud.documentai.v1beta3.Document.Page.IDetectedLanguage[]|null); + + /** Table provenance */ + provenance?: (google.cloud.documentai.v1beta3.Document.IProvenance|null); } /** Represents a Table. */ @@ -22841,6 +22856,9 @@ export namespace google { /** Table detectedLanguages. */ public detectedLanguages: google.cloud.documentai.v1beta3.Document.Page.IDetectedLanguage[]; + /** Table provenance. */ + public provenance?: (google.cloud.documentai.v1beta3.Document.IProvenance|null); + /** * Creates a new Table instance using the specified properties. * @param [properties] Properties to set @@ -23478,6 +23496,215 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of an ImageQualityScores. */ + interface IImageQualityScores { + + /** ImageQualityScores qualityScore */ + qualityScore?: (number|null); + + /** ImageQualityScores detectedDefects */ + detectedDefects?: (google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.IDetectedDefect[]|null); + } + + /** Represents an ImageQualityScores. */ + class ImageQualityScores implements IImageQualityScores { + + /** + * Constructs a new ImageQualityScores. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores); + + /** ImageQualityScores qualityScore. */ + public qualityScore: number; + + /** ImageQualityScores detectedDefects. */ + public detectedDefects: google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.IDetectedDefect[]; + + /** + * Creates a new ImageQualityScores instance using the specified properties. + * @param [properties] Properties to set + * @returns ImageQualityScores instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores): google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores; + + /** + * Encodes the specified ImageQualityScores message. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.verify|verify} messages. + * @param message ImageQualityScores message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImageQualityScores message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.verify|verify} messages. + * @param message ImageQualityScores message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImageQualityScores message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImageQualityScores + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores; + + /** + * Decodes an ImageQualityScores message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImageQualityScores + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores; + + /** + * Verifies an ImageQualityScores message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ImageQualityScores message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImageQualityScores + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores; + + /** + * Creates a plain object from an ImageQualityScores message. Also converts values to other types if specified. + * @param message ImageQualityScores + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImageQualityScores to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImageQualityScores + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ImageQualityScores { + + /** Properties of a DetectedDefect. */ + interface IDetectedDefect { + + /** DetectedDefect type */ + type?: (string|null); + + /** DetectedDefect confidence */ + confidence?: (number|null); + } + + /** Represents a DetectedDefect. */ + class DetectedDefect implements IDetectedDefect { + + /** + * Constructs a new DetectedDefect. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.IDetectedDefect); + + /** DetectedDefect type. */ + public type: string; + + /** DetectedDefect confidence. */ + public confidence: number; + + /** + * Creates a new DetectedDefect instance using the specified properties. + * @param [properties] Properties to set + * @returns DetectedDefect instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.IDetectedDefect): google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect; + + /** + * Encodes the specified DetectedDefect message. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect.verify|verify} messages. + * @param message DetectedDefect message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.IDetectedDefect, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DetectedDefect message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect.verify|verify} messages. + * @param message DetectedDefect message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.IDetectedDefect, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DetectedDefect message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DetectedDefect + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect; + + /** + * Decodes a DetectedDefect message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DetectedDefect + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect; + + /** + * Verifies a DetectedDefect message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DetectedDefect message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DetectedDefect + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect; + + /** + * Creates a plain object from a DetectedDefect message. Also converts values to other types if specified. + * @param message DetectedDefect + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DetectedDefect to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DetectedDefect + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } } /** Properties of an Entity. */ @@ -25848,6 +26075,9 @@ export namespace google { /** GcsOutputConfig gcsUri */ gcsUri?: (string|null); + + /** GcsOutputConfig fieldMask */ + fieldMask?: (google.protobuf.IFieldMask|null); } /** Represents a GcsOutputConfig. */ @@ -25862,6 +26092,9 @@ export namespace google { /** GcsOutputConfig gcsUri. */ public gcsUri: string; + /** GcsOutputConfig fieldMask. */ + public fieldMask?: (google.protobuf.IFieldMask|null); + /** * Creates a new GcsOutputConfig instance using the specified properties. * @param [properties] Properties to set @@ -26045,6 +26278,20 @@ export namespace google { */ public getProcessor(request: google.cloud.documentai.v1beta3.IGetProcessorRequest): Promise; + /** + * Calls TrainProcessorVersion. + * @param request TrainProcessorVersionRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public trainProcessorVersion(request: google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, callback: google.cloud.documentai.v1beta3.DocumentProcessorService.TrainProcessorVersionCallback): void; + + /** + * Calls TrainProcessorVersion. + * @param request TrainProcessorVersionRequest message or plain object + * @returns Promise + */ + public trainProcessorVersion(request: google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest): Promise; + /** * Calls GetProcessorVersion. * @param request GetProcessorVersionRequest message or plain object @@ -26198,6 +26445,48 @@ export namespace google { * @returns Promise */ public reviewDocument(request: google.cloud.documentai.v1beta3.IReviewDocumentRequest): Promise; + + /** + * Calls EvaluateProcessorVersion. + * @param request EvaluateProcessorVersionRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public evaluateProcessorVersion(request: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, callback: google.cloud.documentai.v1beta3.DocumentProcessorService.EvaluateProcessorVersionCallback): void; + + /** + * Calls EvaluateProcessorVersion. + * @param request EvaluateProcessorVersionRequest message or plain object + * @returns Promise + */ + public evaluateProcessorVersion(request: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest): Promise; + + /** + * Calls GetEvaluation. + * @param request GetEvaluationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Evaluation + */ + public getEvaluation(request: google.cloud.documentai.v1beta3.IGetEvaluationRequest, callback: google.cloud.documentai.v1beta3.DocumentProcessorService.GetEvaluationCallback): void; + + /** + * Calls GetEvaluation. + * @param request GetEvaluationRequest message or plain object + * @returns Promise + */ + public getEvaluation(request: google.cloud.documentai.v1beta3.IGetEvaluationRequest): Promise; + + /** + * Calls ListEvaluations. + * @param request ListEvaluationsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListEvaluationsResponse + */ + public listEvaluations(request: google.cloud.documentai.v1beta3.IListEvaluationsRequest, callback: google.cloud.documentai.v1beta3.DocumentProcessorService.ListEvaluationsCallback): void; + + /** + * Calls ListEvaluations. + * @param request ListEvaluationsRequest message or plain object + * @returns Promise + */ + public listEvaluations(request: google.cloud.documentai.v1beta3.IListEvaluationsRequest): Promise; } namespace DocumentProcessorService { @@ -26244,6 +26533,13 @@ export namespace google { */ type GetProcessorCallback = (error: (Error|null), response?: google.cloud.documentai.v1beta3.Processor) => void; + /** + * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|trainProcessorVersion}. + * @param error Error, if any + * @param [response] Operation + */ + type TrainProcessorVersionCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + /** * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|getProcessorVersion}. * @param error Error, if any @@ -26320,13 +26616,34 @@ export namespace google { * @param [response] Operation */ type ReviewDocumentCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; - } - /** Properties of a ProcessRequest. */ - interface IProcessRequest { + /** + * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|evaluateProcessorVersion}. + * @param error Error, if any + * @param [response] Operation + */ + type EvaluateProcessorVersionCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; - /** ProcessRequest inlineDocument */ - inlineDocument?: (google.cloud.documentai.v1beta3.IDocument|null); + /** + * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|getEvaluation}. + * @param error Error, if any + * @param [response] Evaluation + */ + type GetEvaluationCallback = (error: (Error|null), response?: google.cloud.documentai.v1beta3.Evaluation) => void; + + /** + * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|listEvaluations}. + * @param error Error, if any + * @param [response] ListEvaluationsResponse + */ + type ListEvaluationsCallback = (error: (Error|null), response?: google.cloud.documentai.v1beta3.ListEvaluationsResponse) => void; + } + + /** Properties of a ProcessRequest. */ + interface IProcessRequest { + + /** ProcessRequest inlineDocument */ + inlineDocument?: (google.cloud.documentai.v1beta3.IDocument|null); /** ProcessRequest rawDocument */ rawDocument?: (google.cloud.documentai.v1beta3.IRawDocument|null); @@ -30305,980 +30622,2790 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } - /** Properties of a ReviewDocumentRequest. */ - interface IReviewDocumentRequest { - - /** ReviewDocumentRequest inlineDocument */ - inlineDocument?: (google.cloud.documentai.v1beta3.IDocument|null); + /** Properties of a TrainProcessorVersionRequest. */ + interface ITrainProcessorVersionRequest { - /** ReviewDocumentRequest humanReviewConfig */ - humanReviewConfig?: (string|null); + /** TrainProcessorVersionRequest parent */ + parent?: (string|null); - /** ReviewDocumentRequest document */ - document?: (google.cloud.documentai.v1beta3.IDocument|null); + /** TrainProcessorVersionRequest processorVersion */ + processorVersion?: (google.cloud.documentai.v1beta3.IProcessorVersion|null); - /** ReviewDocumentRequest enableSchemaValidation */ - enableSchemaValidation?: (boolean|null); + /** TrainProcessorVersionRequest documentSchema */ + documentSchema?: (google.cloud.documentai.v1beta3.IDocumentSchema|null); - /** ReviewDocumentRequest priority */ - priority?: (google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority|null); + /** TrainProcessorVersionRequest inputData */ + inputData?: (google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData|null); - /** ReviewDocumentRequest documentSchema */ - documentSchema?: (google.cloud.documentai.v1beta3.IDocumentSchema|null); + /** TrainProcessorVersionRequest baseProcessorVersion */ + baseProcessorVersion?: (string|null); } - /** Represents a ReviewDocumentRequest. */ - class ReviewDocumentRequest implements IReviewDocumentRequest { + /** Represents a TrainProcessorVersionRequest. */ + class TrainProcessorVersionRequest implements ITrainProcessorVersionRequest { /** - * Constructs a new ReviewDocumentRequest. + * Constructs a new TrainProcessorVersionRequest. * @param [properties] Properties to set */ - constructor(properties?: google.cloud.documentai.v1beta3.IReviewDocumentRequest); + constructor(properties?: google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest); - /** ReviewDocumentRequest inlineDocument. */ - public inlineDocument?: (google.cloud.documentai.v1beta3.IDocument|null); - - /** ReviewDocumentRequest humanReviewConfig. */ - public humanReviewConfig: string; - - /** ReviewDocumentRequest document. */ - public document?: (google.cloud.documentai.v1beta3.IDocument|null); - - /** ReviewDocumentRequest enableSchemaValidation. */ - public enableSchemaValidation: boolean; + /** TrainProcessorVersionRequest parent. */ + public parent: string; - /** ReviewDocumentRequest priority. */ - public priority: (google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority); + /** TrainProcessorVersionRequest processorVersion. */ + public processorVersion?: (google.cloud.documentai.v1beta3.IProcessorVersion|null); - /** ReviewDocumentRequest documentSchema. */ + /** TrainProcessorVersionRequest documentSchema. */ public documentSchema?: (google.cloud.documentai.v1beta3.IDocumentSchema|null); - /** ReviewDocumentRequest source. */ - public source?: "inlineDocument"; + /** TrainProcessorVersionRequest inputData. */ + public inputData?: (google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData|null); + + /** TrainProcessorVersionRequest baseProcessorVersion. */ + public baseProcessorVersion: string; /** - * Creates a new ReviewDocumentRequest instance using the specified properties. + * Creates a new TrainProcessorVersionRequest instance using the specified properties. * @param [properties] Properties to set - * @returns ReviewDocumentRequest instance + * @returns TrainProcessorVersionRequest instance */ - public static create(properties?: google.cloud.documentai.v1beta3.IReviewDocumentRequest): google.cloud.documentai.v1beta3.ReviewDocumentRequest; + public static create(properties?: google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest): google.cloud.documentai.v1beta3.TrainProcessorVersionRequest; /** - * Encodes the specified ReviewDocumentRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentRequest.verify|verify} messages. - * @param message ReviewDocumentRequest message or plain object to encode + * Encodes the specified TrainProcessorVersionRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.verify|verify} messages. + * @param message TrainProcessorVersionRequest message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.cloud.documentai.v1beta3.IReviewDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified ReviewDocumentRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentRequest.verify|verify} messages. - * @param message ReviewDocumentRequest message or plain object to encode + * Encodes the specified TrainProcessorVersionRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.verify|verify} messages. + * @param message TrainProcessorVersionRequest message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.cloud.documentai.v1beta3.IReviewDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a ReviewDocumentRequest message from the specified reader or buffer. + * Decodes a TrainProcessorVersionRequest message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns ReviewDocumentRequest + * @returns TrainProcessorVersionRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.ReviewDocumentRequest; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.TrainProcessorVersionRequest; /** - * Decodes a ReviewDocumentRequest message from the specified reader or buffer, length delimited. + * Decodes a TrainProcessorVersionRequest message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns ReviewDocumentRequest + * @returns TrainProcessorVersionRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.ReviewDocumentRequest; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.TrainProcessorVersionRequest; /** - * Verifies a ReviewDocumentRequest message. + * Verifies a TrainProcessorVersionRequest message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates a ReviewDocumentRequest message from a plain object. Also converts values to their respective internal types. + * Creates a TrainProcessorVersionRequest message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns ReviewDocumentRequest + * @returns TrainProcessorVersionRequest */ - public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ReviewDocumentRequest; + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.TrainProcessorVersionRequest; /** - * Creates a plain object from a ReviewDocumentRequest message. Also converts values to other types if specified. - * @param message ReviewDocumentRequest + * Creates a plain object from a TrainProcessorVersionRequest message. Also converts values to other types if specified. + * @param message TrainProcessorVersionRequest * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.cloud.documentai.v1beta3.ReviewDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.cloud.documentai.v1beta3.TrainProcessorVersionRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this ReviewDocumentRequest to JSON. + * Converts this TrainProcessorVersionRequest to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; /** - * Gets the default type url for ReviewDocumentRequest + * Gets the default type url for TrainProcessorVersionRequest * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns The default type url */ public static getTypeUrl(typeUrlPrefix?: string): string; } - namespace ReviewDocumentRequest { + namespace TrainProcessorVersionRequest { - /** Priority enum. */ - enum Priority { - DEFAULT = 0, - URGENT = 1 + /** Properties of an InputData. */ + interface IInputData { + + /** InputData trainingDocuments */ + trainingDocuments?: (google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null); + + /** InputData testDocuments */ + testDocuments?: (google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null); } - } - /** Properties of a ReviewDocumentResponse. */ - interface IReviewDocumentResponse { + /** Represents an InputData. */ + class InputData implements IInputData { - /** ReviewDocumentResponse gcsDestination */ - gcsDestination?: (string|null); + /** + * Constructs a new InputData. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData); - /** ReviewDocumentResponse state */ - state?: (google.cloud.documentai.v1beta3.ReviewDocumentResponse.State|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentResponse.State|null); + /** InputData trainingDocuments. */ + public trainingDocuments?: (google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null); - /** ReviewDocumentResponse rejectionReason */ - rejectionReason?: (string|null); + /** InputData testDocuments. */ + public testDocuments?: (google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null); + + /** + * Creates a new InputData instance using the specified properties. + * @param [properties] Properties to set + * @returns InputData instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData): google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData; + + /** + * Encodes the specified InputData message. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.verify|verify} messages. + * @param message InputData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified InputData message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.verify|verify} messages. + * @param message InputData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an InputData message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns InputData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData; + + /** + * Decodes an InputData message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns InputData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData; + + /** + * Verifies an InputData message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an InputData message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns InputData + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData; + + /** + * Creates a plain object from an InputData message. Also converts values to other types if specified. + * @param message InputData + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this InputData to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for InputData + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } - /** Represents a ReviewDocumentResponse. */ - class ReviewDocumentResponse implements IReviewDocumentResponse { + /** Properties of a TrainProcessorVersionResponse. */ + interface ITrainProcessorVersionResponse { + + /** TrainProcessorVersionResponse processorVersion */ + processorVersion?: (string|null); + } + + /** Represents a TrainProcessorVersionResponse. */ + class TrainProcessorVersionResponse implements ITrainProcessorVersionResponse { /** - * Constructs a new ReviewDocumentResponse. + * Constructs a new TrainProcessorVersionResponse. * @param [properties] Properties to set */ - constructor(properties?: google.cloud.documentai.v1beta3.IReviewDocumentResponse); - - /** ReviewDocumentResponse gcsDestination. */ - public gcsDestination: string; - - /** ReviewDocumentResponse state. */ - public state: (google.cloud.documentai.v1beta3.ReviewDocumentResponse.State|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentResponse.State); + constructor(properties?: google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse); - /** ReviewDocumentResponse rejectionReason. */ - public rejectionReason: string; + /** TrainProcessorVersionResponse processorVersion. */ + public processorVersion: string; /** - * Creates a new ReviewDocumentResponse instance using the specified properties. + * Creates a new TrainProcessorVersionResponse instance using the specified properties. * @param [properties] Properties to set - * @returns ReviewDocumentResponse instance + * @returns TrainProcessorVersionResponse instance */ - public static create(properties?: google.cloud.documentai.v1beta3.IReviewDocumentResponse): google.cloud.documentai.v1beta3.ReviewDocumentResponse; + public static create(properties?: google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse): google.cloud.documentai.v1beta3.TrainProcessorVersionResponse; /** - * Encodes the specified ReviewDocumentResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentResponse.verify|verify} messages. - * @param message ReviewDocumentResponse message or plain object to encode + * Encodes the specified TrainProcessorVersionResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionResponse.verify|verify} messages. + * @param message TrainProcessorVersionResponse message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.cloud.documentai.v1beta3.IReviewDocumentResponse, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified ReviewDocumentResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentResponse.verify|verify} messages. - * @param message ReviewDocumentResponse message or plain object to encode + * Encodes the specified TrainProcessorVersionResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionResponse.verify|verify} messages. + * @param message TrainProcessorVersionResponse message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.cloud.documentai.v1beta3.IReviewDocumentResponse, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a ReviewDocumentResponse message from the specified reader or buffer. + * Decodes a TrainProcessorVersionResponse message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns ReviewDocumentResponse + * @returns TrainProcessorVersionResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.ReviewDocumentResponse; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.TrainProcessorVersionResponse; /** - * Decodes a ReviewDocumentResponse message from the specified reader or buffer, length delimited. + * Decodes a TrainProcessorVersionResponse message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns ReviewDocumentResponse + * @returns TrainProcessorVersionResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.ReviewDocumentResponse; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.TrainProcessorVersionResponse; /** - * Verifies a ReviewDocumentResponse message. + * Verifies a TrainProcessorVersionResponse message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates a ReviewDocumentResponse message from a plain object. Also converts values to their respective internal types. + * Creates a TrainProcessorVersionResponse message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns ReviewDocumentResponse + * @returns TrainProcessorVersionResponse */ - public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ReviewDocumentResponse; + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.TrainProcessorVersionResponse; /** - * Creates a plain object from a ReviewDocumentResponse message. Also converts values to other types if specified. - * @param message ReviewDocumentResponse + * Creates a plain object from a TrainProcessorVersionResponse message. Also converts values to other types if specified. + * @param message TrainProcessorVersionResponse * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.cloud.documentai.v1beta3.ReviewDocumentResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.cloud.documentai.v1beta3.TrainProcessorVersionResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this ReviewDocumentResponse to JSON. + * Converts this TrainProcessorVersionResponse to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; /** - * Gets the default type url for ReviewDocumentResponse + * Gets the default type url for TrainProcessorVersionResponse * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns The default type url */ public static getTypeUrl(typeUrlPrefix?: string): string; } - namespace ReviewDocumentResponse { - - /** State enum. */ - enum State { - STATE_UNSPECIFIED = 0, - REJECTED = 1, - SUCCEEDED = 2 - } - } - - /** Properties of a ReviewDocumentOperationMetadata. */ - interface IReviewDocumentOperationMetadata { - - /** ReviewDocumentOperationMetadata state */ - state?: (google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State|null); - - /** ReviewDocumentOperationMetadata stateMessage */ - stateMessage?: (string|null); - - /** ReviewDocumentOperationMetadata createTime */ - createTime?: (google.protobuf.ITimestamp|null); - - /** ReviewDocumentOperationMetadata updateTime */ - updateTime?: (google.protobuf.ITimestamp|null); + /** Properties of a TrainProcessorVersionMetadata. */ + interface ITrainProcessorVersionMetadata { - /** ReviewDocumentOperationMetadata commonMetadata */ + /** TrainProcessorVersionMetadata commonMetadata */ commonMetadata?: (google.cloud.documentai.v1beta3.ICommonOperationMetadata|null); - /** ReviewDocumentOperationMetadata questionId */ - questionId?: (string|null); + /** TrainProcessorVersionMetadata trainingDatasetValidation */ + trainingDatasetValidation?: (google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation|null); + + /** TrainProcessorVersionMetadata testDatasetValidation */ + testDatasetValidation?: (google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation|null); } - /** Represents a ReviewDocumentOperationMetadata. */ - class ReviewDocumentOperationMetadata implements IReviewDocumentOperationMetadata { + /** Represents a TrainProcessorVersionMetadata. */ + class TrainProcessorVersionMetadata implements ITrainProcessorVersionMetadata { /** - * Constructs a new ReviewDocumentOperationMetadata. + * Constructs a new TrainProcessorVersionMetadata. * @param [properties] Properties to set */ - constructor(properties?: google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata); - - /** ReviewDocumentOperationMetadata state. */ - public state: (google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State); - - /** ReviewDocumentOperationMetadata stateMessage. */ - public stateMessage: string; + constructor(properties?: google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata); - /** ReviewDocumentOperationMetadata createTime. */ - public createTime?: (google.protobuf.ITimestamp|null); - - /** ReviewDocumentOperationMetadata updateTime. */ - public updateTime?: (google.protobuf.ITimestamp|null); - - /** ReviewDocumentOperationMetadata commonMetadata. */ + /** TrainProcessorVersionMetadata commonMetadata. */ public commonMetadata?: (google.cloud.documentai.v1beta3.ICommonOperationMetadata|null); - /** ReviewDocumentOperationMetadata questionId. */ - public questionId: string; + /** TrainProcessorVersionMetadata trainingDatasetValidation. */ + public trainingDatasetValidation?: (google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation|null); + + /** TrainProcessorVersionMetadata testDatasetValidation. */ + public testDatasetValidation?: (google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation|null); /** - * Creates a new ReviewDocumentOperationMetadata instance using the specified properties. + * Creates a new TrainProcessorVersionMetadata instance using the specified properties. * @param [properties] Properties to set - * @returns ReviewDocumentOperationMetadata instance + * @returns TrainProcessorVersionMetadata instance */ - public static create(properties?: google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata): google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata; + public static create(properties?: google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata): google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata; /** - * Encodes the specified ReviewDocumentOperationMetadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.verify|verify} messages. - * @param message ReviewDocumentOperationMetadata message or plain object to encode + * Encodes the specified TrainProcessorVersionMetadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.verify|verify} messages. + * @param message TrainProcessorVersionMetadata message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified ReviewDocumentOperationMetadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.verify|verify} messages. - * @param message ReviewDocumentOperationMetadata message or plain object to encode + * Encodes the specified TrainProcessorVersionMetadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.verify|verify} messages. + * @param message TrainProcessorVersionMetadata message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a ReviewDocumentOperationMetadata message from the specified reader or buffer. + * Decodes a TrainProcessorVersionMetadata message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns ReviewDocumentOperationMetadata + * @returns TrainProcessorVersionMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata; /** - * Decodes a ReviewDocumentOperationMetadata message from the specified reader or buffer, length delimited. + * Decodes a TrainProcessorVersionMetadata message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns ReviewDocumentOperationMetadata + * @returns TrainProcessorVersionMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata; /** - * Verifies a ReviewDocumentOperationMetadata message. + * Verifies a TrainProcessorVersionMetadata message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates a ReviewDocumentOperationMetadata message from a plain object. Also converts values to their respective internal types. + * Creates a TrainProcessorVersionMetadata message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns ReviewDocumentOperationMetadata + * @returns TrainProcessorVersionMetadata */ - public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata; + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata; /** - * Creates a plain object from a ReviewDocumentOperationMetadata message. Also converts values to other types if specified. - * @param message ReviewDocumentOperationMetadata + * Creates a plain object from a TrainProcessorVersionMetadata message. Also converts values to other types if specified. + * @param message TrainProcessorVersionMetadata * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this ReviewDocumentOperationMetadata to JSON. + * Converts this TrainProcessorVersionMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TrainProcessorVersionMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace TrainProcessorVersionMetadata { + + /** Properties of a DatasetValidation. */ + interface IDatasetValidation { + + /** DatasetValidation documentErrorCount */ + documentErrorCount?: (number|null); + + /** DatasetValidation datasetErrorCount */ + datasetErrorCount?: (number|null); + + /** DatasetValidation documentErrors */ + documentErrors?: (google.rpc.IStatus[]|null); + + /** DatasetValidation datasetErrors */ + datasetErrors?: (google.rpc.IStatus[]|null); + } + + /** Represents a DatasetValidation. */ + class DatasetValidation implements IDatasetValidation { + + /** + * Constructs a new DatasetValidation. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation); + + /** DatasetValidation documentErrorCount. */ + public documentErrorCount: number; + + /** DatasetValidation datasetErrorCount. */ + public datasetErrorCount: number; + + /** DatasetValidation documentErrors. */ + public documentErrors: google.rpc.IStatus[]; + + /** DatasetValidation datasetErrors. */ + public datasetErrors: google.rpc.IStatus[]; + + /** + * Creates a new DatasetValidation instance using the specified properties. + * @param [properties] Properties to set + * @returns DatasetValidation instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation): google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation; + + /** + * Encodes the specified DatasetValidation message. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.verify|verify} messages. + * @param message DatasetValidation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DatasetValidation message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.verify|verify} messages. + * @param message DatasetValidation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DatasetValidation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DatasetValidation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation; + + /** + * Decodes a DatasetValidation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DatasetValidation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation; + + /** + * Verifies a DatasetValidation message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DatasetValidation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DatasetValidation + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation; + + /** + * Creates a plain object from a DatasetValidation message. Also converts values to other types if specified. + * @param message DatasetValidation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DatasetValidation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DatasetValidation + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a ReviewDocumentRequest. */ + interface IReviewDocumentRequest { + + /** ReviewDocumentRequest inlineDocument */ + inlineDocument?: (google.cloud.documentai.v1beta3.IDocument|null); + + /** ReviewDocumentRequest humanReviewConfig */ + humanReviewConfig?: (string|null); + + /** ReviewDocumentRequest document */ + document?: (google.cloud.documentai.v1beta3.IDocument|null); + + /** ReviewDocumentRequest enableSchemaValidation */ + enableSchemaValidation?: (boolean|null); + + /** ReviewDocumentRequest priority */ + priority?: (google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority|null); + + /** ReviewDocumentRequest documentSchema */ + documentSchema?: (google.cloud.documentai.v1beta3.IDocumentSchema|null); + } + + /** Represents a ReviewDocumentRequest. */ + class ReviewDocumentRequest implements IReviewDocumentRequest { + + /** + * Constructs a new ReviewDocumentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IReviewDocumentRequest); + + /** ReviewDocumentRequest inlineDocument. */ + public inlineDocument?: (google.cloud.documentai.v1beta3.IDocument|null); + + /** ReviewDocumentRequest humanReviewConfig. */ + public humanReviewConfig: string; + + /** ReviewDocumentRequest document. */ + public document?: (google.cloud.documentai.v1beta3.IDocument|null); + + /** ReviewDocumentRequest enableSchemaValidation. */ + public enableSchemaValidation: boolean; + + /** ReviewDocumentRequest priority. */ + public priority: (google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority); + + /** ReviewDocumentRequest documentSchema. */ + public documentSchema?: (google.cloud.documentai.v1beta3.IDocumentSchema|null); + + /** ReviewDocumentRequest source. */ + public source?: "inlineDocument"; + + /** + * Creates a new ReviewDocumentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ReviewDocumentRequest instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IReviewDocumentRequest): google.cloud.documentai.v1beta3.ReviewDocumentRequest; + + /** + * Encodes the specified ReviewDocumentRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentRequest.verify|verify} messages. + * @param message ReviewDocumentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IReviewDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReviewDocumentRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentRequest.verify|verify} messages. + * @param message ReviewDocumentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IReviewDocumentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReviewDocumentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReviewDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.ReviewDocumentRequest; + + /** + * Decodes a ReviewDocumentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReviewDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.ReviewDocumentRequest; + + /** + * Verifies a ReviewDocumentRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ReviewDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReviewDocumentRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ReviewDocumentRequest; + + /** + * Creates a plain object from a ReviewDocumentRequest message. Also converts values to other types if specified. + * @param message ReviewDocumentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.ReviewDocumentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReviewDocumentRequest to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; - /** - * Gets the default type url for ReviewDocumentOperationMetadata - * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns The default type url - */ - public static getTypeUrl(typeUrlPrefix?: string): string; - } + /** + * Gets the default type url for ReviewDocumentRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ReviewDocumentRequest { + + /** Priority enum. */ + enum Priority { + DEFAULT = 0, + URGENT = 1 + } + } + + /** Properties of a ReviewDocumentResponse. */ + interface IReviewDocumentResponse { + + /** ReviewDocumentResponse gcsDestination */ + gcsDestination?: (string|null); + + /** ReviewDocumentResponse state */ + state?: (google.cloud.documentai.v1beta3.ReviewDocumentResponse.State|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentResponse.State|null); + + /** ReviewDocumentResponse rejectionReason */ + rejectionReason?: (string|null); + } + + /** Represents a ReviewDocumentResponse. */ + class ReviewDocumentResponse implements IReviewDocumentResponse { + + /** + * Constructs a new ReviewDocumentResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IReviewDocumentResponse); + + /** ReviewDocumentResponse gcsDestination. */ + public gcsDestination: string; + + /** ReviewDocumentResponse state. */ + public state: (google.cloud.documentai.v1beta3.ReviewDocumentResponse.State|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentResponse.State); + + /** ReviewDocumentResponse rejectionReason. */ + public rejectionReason: string; + + /** + * Creates a new ReviewDocumentResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ReviewDocumentResponse instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IReviewDocumentResponse): google.cloud.documentai.v1beta3.ReviewDocumentResponse; + + /** + * Encodes the specified ReviewDocumentResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentResponse.verify|verify} messages. + * @param message ReviewDocumentResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IReviewDocumentResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReviewDocumentResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentResponse.verify|verify} messages. + * @param message ReviewDocumentResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IReviewDocumentResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReviewDocumentResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReviewDocumentResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.ReviewDocumentResponse; + + /** + * Decodes a ReviewDocumentResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReviewDocumentResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.ReviewDocumentResponse; + + /** + * Verifies a ReviewDocumentResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ReviewDocumentResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReviewDocumentResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ReviewDocumentResponse; + + /** + * Creates a plain object from a ReviewDocumentResponse message. Also converts values to other types if specified. + * @param message ReviewDocumentResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.ReviewDocumentResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReviewDocumentResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReviewDocumentResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ReviewDocumentResponse { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + REJECTED = 1, + SUCCEEDED = 2 + } + } + + /** Properties of a ReviewDocumentOperationMetadata. */ + interface IReviewDocumentOperationMetadata { + + /** ReviewDocumentOperationMetadata state */ + state?: (google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State|null); + + /** ReviewDocumentOperationMetadata stateMessage */ + stateMessage?: (string|null); + + /** ReviewDocumentOperationMetadata createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** ReviewDocumentOperationMetadata updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** ReviewDocumentOperationMetadata commonMetadata */ + commonMetadata?: (google.cloud.documentai.v1beta3.ICommonOperationMetadata|null); + + /** ReviewDocumentOperationMetadata questionId */ + questionId?: (string|null); + } + + /** Represents a ReviewDocumentOperationMetadata. */ + class ReviewDocumentOperationMetadata implements IReviewDocumentOperationMetadata { + + /** + * Constructs a new ReviewDocumentOperationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata); + + /** ReviewDocumentOperationMetadata state. */ + public state: (google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State|keyof typeof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State); + + /** ReviewDocumentOperationMetadata stateMessage. */ + public stateMessage: string; + + /** ReviewDocumentOperationMetadata createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** ReviewDocumentOperationMetadata updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** ReviewDocumentOperationMetadata commonMetadata. */ + public commonMetadata?: (google.cloud.documentai.v1beta3.ICommonOperationMetadata|null); + + /** ReviewDocumentOperationMetadata questionId. */ + public questionId: string; + + /** + * Creates a new ReviewDocumentOperationMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns ReviewDocumentOperationMetadata instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata): google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata; + + /** + * Encodes the specified ReviewDocumentOperationMetadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.verify|verify} messages. + * @param message ReviewDocumentOperationMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReviewDocumentOperationMetadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.verify|verify} messages. + * @param message ReviewDocumentOperationMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReviewDocumentOperationMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReviewDocumentOperationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata; + + /** + * Decodes a ReviewDocumentOperationMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReviewDocumentOperationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata; + + /** + * Verifies a ReviewDocumentOperationMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ReviewDocumentOperationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReviewDocumentOperationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata; + + /** + * Creates a plain object from a ReviewDocumentOperationMetadata message. Also converts values to other types if specified. + * @param message ReviewDocumentOperationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReviewDocumentOperationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReviewDocumentOperationMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ReviewDocumentOperationMetadata { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + RUNNING = 1, + CANCELLING = 2, + SUCCEEDED = 3, + FAILED = 4, + CANCELLED = 5 + } + } + + /** Properties of an EvaluateProcessorVersionRequest. */ + interface IEvaluateProcessorVersionRequest { + + /** EvaluateProcessorVersionRequest processorVersion */ + processorVersion?: (string|null); + + /** EvaluateProcessorVersionRequest evaluationDocuments */ + evaluationDocuments?: (google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null); + } + + /** Represents an EvaluateProcessorVersionRequest. */ + class EvaluateProcessorVersionRequest implements IEvaluateProcessorVersionRequest { + + /** + * Constructs a new EvaluateProcessorVersionRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest); + + /** EvaluateProcessorVersionRequest processorVersion. */ + public processorVersion: string; + + /** EvaluateProcessorVersionRequest evaluationDocuments. */ + public evaluationDocuments?: (google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null); + + /** + * Creates a new EvaluateProcessorVersionRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns EvaluateProcessorVersionRequest instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest): google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest; + + /** + * Encodes the specified EvaluateProcessorVersionRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest.verify|verify} messages. + * @param message EvaluateProcessorVersionRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EvaluateProcessorVersionRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest.verify|verify} messages. + * @param message EvaluateProcessorVersionRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EvaluateProcessorVersionRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EvaluateProcessorVersionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest; + + /** + * Decodes an EvaluateProcessorVersionRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EvaluateProcessorVersionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest; + + /** + * Verifies an EvaluateProcessorVersionRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EvaluateProcessorVersionRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EvaluateProcessorVersionRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest; + + /** + * Creates a plain object from an EvaluateProcessorVersionRequest message. Also converts values to other types if specified. + * @param message EvaluateProcessorVersionRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EvaluateProcessorVersionRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EvaluateProcessorVersionRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an EvaluateProcessorVersionMetadata. */ + interface IEvaluateProcessorVersionMetadata { + + /** EvaluateProcessorVersionMetadata commonMetadata */ + commonMetadata?: (google.cloud.documentai.v1beta3.ICommonOperationMetadata|null); + } + + /** Represents an EvaluateProcessorVersionMetadata. */ + class EvaluateProcessorVersionMetadata implements IEvaluateProcessorVersionMetadata { + + /** + * Constructs a new EvaluateProcessorVersionMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata); + + /** EvaluateProcessorVersionMetadata commonMetadata. */ + public commonMetadata?: (google.cloud.documentai.v1beta3.ICommonOperationMetadata|null); + + /** + * Creates a new EvaluateProcessorVersionMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns EvaluateProcessorVersionMetadata instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata): google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata; + + /** + * Encodes the specified EvaluateProcessorVersionMetadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata.verify|verify} messages. + * @param message EvaluateProcessorVersionMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EvaluateProcessorVersionMetadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata.verify|verify} messages. + * @param message EvaluateProcessorVersionMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EvaluateProcessorVersionMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EvaluateProcessorVersionMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata; + + /** + * Decodes an EvaluateProcessorVersionMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EvaluateProcessorVersionMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata; + + /** + * Verifies an EvaluateProcessorVersionMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EvaluateProcessorVersionMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EvaluateProcessorVersionMetadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata; + + /** + * Creates a plain object from an EvaluateProcessorVersionMetadata message. Also converts values to other types if specified. + * @param message EvaluateProcessorVersionMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EvaluateProcessorVersionMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EvaluateProcessorVersionMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an EvaluateProcessorVersionResponse. */ + interface IEvaluateProcessorVersionResponse { + + /** EvaluateProcessorVersionResponse evaluation */ + evaluation?: (string|null); + } + + /** Represents an EvaluateProcessorVersionResponse. */ + class EvaluateProcessorVersionResponse implements IEvaluateProcessorVersionResponse { + + /** + * Constructs a new EvaluateProcessorVersionResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse); + + /** EvaluateProcessorVersionResponse evaluation. */ + public evaluation: string; + + /** + * Creates a new EvaluateProcessorVersionResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns EvaluateProcessorVersionResponse instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse): google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse; + + /** + * Encodes the specified EvaluateProcessorVersionResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse.verify|verify} messages. + * @param message EvaluateProcessorVersionResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EvaluateProcessorVersionResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse.verify|verify} messages. + * @param message EvaluateProcessorVersionResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EvaluateProcessorVersionResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EvaluateProcessorVersionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse; + + /** + * Decodes an EvaluateProcessorVersionResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EvaluateProcessorVersionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse; + + /** + * Verifies an EvaluateProcessorVersionResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EvaluateProcessorVersionResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EvaluateProcessorVersionResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse; + + /** + * Creates a plain object from an EvaluateProcessorVersionResponse message. Also converts values to other types if specified. + * @param message EvaluateProcessorVersionResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EvaluateProcessorVersionResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EvaluateProcessorVersionResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetEvaluationRequest. */ + interface IGetEvaluationRequest { + + /** GetEvaluationRequest name */ + name?: (string|null); + } + + /** Represents a GetEvaluationRequest. */ + class GetEvaluationRequest implements IGetEvaluationRequest { + + /** + * Constructs a new GetEvaluationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IGetEvaluationRequest); + + /** GetEvaluationRequest name. */ + public name: string; + + /** + * Creates a new GetEvaluationRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetEvaluationRequest instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IGetEvaluationRequest): google.cloud.documentai.v1beta3.GetEvaluationRequest; + + /** + * Encodes the specified GetEvaluationRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.GetEvaluationRequest.verify|verify} messages. + * @param message GetEvaluationRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IGetEvaluationRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetEvaluationRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.GetEvaluationRequest.verify|verify} messages. + * @param message GetEvaluationRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IGetEvaluationRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetEvaluationRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetEvaluationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.GetEvaluationRequest; + + /** + * Decodes a GetEvaluationRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetEvaluationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.GetEvaluationRequest; + + /** + * Verifies a GetEvaluationRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetEvaluationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetEvaluationRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.GetEvaluationRequest; + + /** + * Creates a plain object from a GetEvaluationRequest message. Also converts values to other types if specified. + * @param message GetEvaluationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.GetEvaluationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetEvaluationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetEvaluationRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListEvaluationsRequest. */ + interface IListEvaluationsRequest { + + /** ListEvaluationsRequest parent */ + parent?: (string|null); + + /** ListEvaluationsRequest pageSize */ + pageSize?: (number|null); + + /** ListEvaluationsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListEvaluationsRequest. */ + class ListEvaluationsRequest implements IListEvaluationsRequest { + + /** + * Constructs a new ListEvaluationsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IListEvaluationsRequest); + + /** ListEvaluationsRequest parent. */ + public parent: string; + + /** ListEvaluationsRequest pageSize. */ + public pageSize: number; + + /** ListEvaluationsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListEvaluationsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListEvaluationsRequest instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IListEvaluationsRequest): google.cloud.documentai.v1beta3.ListEvaluationsRequest; + + /** + * Encodes the specified ListEvaluationsRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.ListEvaluationsRequest.verify|verify} messages. + * @param message ListEvaluationsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IListEvaluationsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListEvaluationsRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ListEvaluationsRequest.verify|verify} messages. + * @param message ListEvaluationsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IListEvaluationsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListEvaluationsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListEvaluationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.ListEvaluationsRequest; + + /** + * Decodes a ListEvaluationsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListEvaluationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.ListEvaluationsRequest; + + /** + * Verifies a ListEvaluationsRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListEvaluationsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListEvaluationsRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ListEvaluationsRequest; + + /** + * Creates a plain object from a ListEvaluationsRequest message. Also converts values to other types if specified. + * @param message ListEvaluationsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.ListEvaluationsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListEvaluationsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListEvaluationsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListEvaluationsResponse. */ + interface IListEvaluationsResponse { + + /** ListEvaluationsResponse evaluations */ + evaluations?: (google.cloud.documentai.v1beta3.IEvaluation[]|null); + + /** ListEvaluationsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListEvaluationsResponse. */ + class ListEvaluationsResponse implements IListEvaluationsResponse { + + /** + * Constructs a new ListEvaluationsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IListEvaluationsResponse); + + /** ListEvaluationsResponse evaluations. */ + public evaluations: google.cloud.documentai.v1beta3.IEvaluation[]; + + /** ListEvaluationsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListEvaluationsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListEvaluationsResponse instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IListEvaluationsResponse): google.cloud.documentai.v1beta3.ListEvaluationsResponse; + + /** + * Encodes the specified ListEvaluationsResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.ListEvaluationsResponse.verify|verify} messages. + * @param message ListEvaluationsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IListEvaluationsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListEvaluationsResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ListEvaluationsResponse.verify|verify} messages. + * @param message ListEvaluationsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IListEvaluationsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListEvaluationsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListEvaluationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.ListEvaluationsResponse; + + /** + * Decodes a ListEvaluationsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListEvaluationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.ListEvaluationsResponse; + + /** + * Verifies a ListEvaluationsResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListEvaluationsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListEvaluationsResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.ListEvaluationsResponse; + + /** + * Creates a plain object from a ListEvaluationsResponse message. Also converts values to other types if specified. + * @param message ListEvaluationsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.ListEvaluationsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListEvaluationsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListEvaluationsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DocumentSchema. */ + interface IDocumentSchema { + + /** DocumentSchema displayName */ + displayName?: (string|null); + + /** DocumentSchema description */ + description?: (string|null); + + /** DocumentSchema entityTypes */ + entityTypes?: (google.cloud.documentai.v1beta3.DocumentSchema.IEntityType[]|null); + + /** DocumentSchema metadata */ + metadata?: (google.cloud.documentai.v1beta3.DocumentSchema.IMetadata|null); + } + + /** Represents a DocumentSchema. */ + class DocumentSchema implements IDocumentSchema { + + /** + * Constructs a new DocumentSchema. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.IDocumentSchema); + + /** DocumentSchema displayName. */ + public displayName: string; + + /** DocumentSchema description. */ + public description: string; + + /** DocumentSchema entityTypes. */ + public entityTypes: google.cloud.documentai.v1beta3.DocumentSchema.IEntityType[]; + + /** DocumentSchema metadata. */ + public metadata?: (google.cloud.documentai.v1beta3.DocumentSchema.IMetadata|null); + + /** + * Creates a new DocumentSchema instance using the specified properties. + * @param [properties] Properties to set + * @returns DocumentSchema instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.IDocumentSchema): google.cloud.documentai.v1beta3.DocumentSchema; + + /** + * Encodes the specified DocumentSchema message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.verify|verify} messages. + * @param message DocumentSchema message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.IDocumentSchema, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DocumentSchema message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.verify|verify} messages. + * @param message DocumentSchema message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IDocumentSchema, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DocumentSchema message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DocumentSchema + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.DocumentSchema; + + /** + * Decodes a DocumentSchema message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DocumentSchema + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.DocumentSchema; + + /** + * Verifies a DocumentSchema message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DocumentSchema message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DocumentSchema + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.DocumentSchema; + + /** + * Creates a plain object from a DocumentSchema message. Also converts values to other types if specified. + * @param message DocumentSchema + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.DocumentSchema, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DocumentSchema to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DocumentSchema + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace DocumentSchema { + + /** Properties of an EntityType. */ + interface IEntityType { + + /** EntityType enumValues */ + enumValues?: (google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues|null); + + /** EntityType displayName */ + displayName?: (string|null); + + /** EntityType name */ + name?: (string|null); + + /** EntityType baseTypes */ + baseTypes?: (string[]|null); + + /** EntityType properties */ + properties?: (google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty[]|null); + } + + /** Represents an EntityType. */ + class EntityType implements IEntityType { + + /** + * Constructs a new EntityType. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.DocumentSchema.IEntityType); + + /** EntityType enumValues. */ + public enumValues?: (google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues|null); + + /** EntityType displayName. */ + public displayName: string; + + /** EntityType name. */ + public name: string; + + /** EntityType baseTypes. */ + public baseTypes: string[]; + + /** EntityType properties. */ + public properties: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty[]; + + /** EntityType valueSource. */ + public valueSource?: "enumValues"; + + /** + * Creates a new EntityType instance using the specified properties. + * @param [properties] Properties to set + * @returns EntityType instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.DocumentSchema.IEntityType): google.cloud.documentai.v1beta3.DocumentSchema.EntityType; + + /** + * Encodes the specified EntityType message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.verify|verify} messages. + * @param message EntityType message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.DocumentSchema.IEntityType, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EntityType message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.verify|verify} messages. + * @param message EntityType message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.DocumentSchema.IEntityType, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EntityType message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EntityType + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.DocumentSchema.EntityType; + + /** + * Decodes an EntityType message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EntityType + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.DocumentSchema.EntityType; + + /** + * Verifies an EntityType message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EntityType message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EntityType + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.DocumentSchema.EntityType; + + /** + * Creates a plain object from an EntityType message. Also converts values to other types if specified. + * @param message EntityType + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EntityType to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EntityType + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace EntityType { + + /** Properties of an EnumValues. */ + interface IEnumValues { + + /** EnumValues values */ + values?: (string[]|null); + } + + /** Represents an EnumValues. */ + class EnumValues implements IEnumValues { + + /** + * Constructs a new EnumValues. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues); + + /** EnumValues values. */ + public values: string[]; + + /** + * Creates a new EnumValues instance using the specified properties. + * @param [properties] Properties to set + * @returns EnumValues instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues; + + /** + * Encodes the specified EnumValues message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.verify|verify} messages. + * @param message EnumValues message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EnumValues message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.verify|verify} messages. + * @param message EnumValues message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EnumValues message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EnumValues + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues; + + /** + * Decodes an EnumValues message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EnumValues + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues; + + /** + * Verifies an EnumValues message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EnumValues message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValues + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues; + + /** + * Creates a plain object from an EnumValues message. Also converts values to other types if specified. + * @param message EnumValues + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValues to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumValues + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Property. */ + interface IProperty { + + /** Property name */ + name?: (string|null); + + /** Property valueType */ + valueType?: (string|null); + + /** Property occurrenceType */ + occurrenceType?: (google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType|keyof typeof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType|null); + } + + /** Represents a Property. */ + class Property implements IProperty { + + /** + * Constructs a new Property. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty); + + /** Property name. */ + public name: string; + + /** Property valueType. */ + public valueType: string; + + /** Property occurrenceType. */ + public occurrenceType: (google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType|keyof typeof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType); + + /** + * Creates a new Property instance using the specified properties. + * @param [properties] Properties to set + * @returns Property instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property; + + /** + * Encodes the specified Property message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.verify|verify} messages. + * @param message Property message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Property message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.verify|verify} messages. + * @param message Property message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Property message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Property + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property; + + /** + * Decodes a Property message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Property + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property; + + /** + * Verifies a Property message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Property message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Property + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property; + + /** + * Creates a plain object from a Property message. Also converts values to other types if specified. + * @param message Property + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Property to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Property + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Property { + + /** OccurrenceType enum. */ + enum OccurrenceType { + OCCURRENCE_TYPE_UNSPECIFIED = 0, + OPTIONAL_ONCE = 1, + OPTIONAL_MULTIPLE = 2, + REQUIRED_ONCE = 3, + REQUIRED_MULTIPLE = 4 + } + } + } + + /** Properties of a Metadata. */ + interface IMetadata { + + /** Metadata documentSplitter */ + documentSplitter?: (boolean|null); + + /** Metadata documentAllowMultipleLabels */ + documentAllowMultipleLabels?: (boolean|null); + + /** Metadata prefixedNamingOnProperties */ + prefixedNamingOnProperties?: (boolean|null); + + /** Metadata skipNamingValidation */ + skipNamingValidation?: (boolean|null); + } + + /** Represents a Metadata. */ + class Metadata implements IMetadata { + + /** + * Constructs a new Metadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.DocumentSchema.IMetadata); + + /** Metadata documentSplitter. */ + public documentSplitter: boolean; + + /** Metadata documentAllowMultipleLabels. */ + public documentAllowMultipleLabels: boolean; + + /** Metadata prefixedNamingOnProperties. */ + public prefixedNamingOnProperties: boolean; + + /** Metadata skipNamingValidation. */ + public skipNamingValidation: boolean; + + /** + * Creates a new Metadata instance using the specified properties. + * @param [properties] Properties to set + * @returns Metadata instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.DocumentSchema.IMetadata): google.cloud.documentai.v1beta3.DocumentSchema.Metadata; + + /** + * Encodes the specified Metadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.Metadata.verify|verify} messages. + * @param message Metadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.DocumentSchema.IMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Metadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.Metadata.verify|verify} messages. + * @param message Metadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.DocumentSchema.IMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Metadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Metadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.DocumentSchema.Metadata; + + /** + * Decodes a Metadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Metadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.DocumentSchema.Metadata; + + /** + * Verifies a Metadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Metadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Metadata + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.DocumentSchema.Metadata; + + /** + * Creates a plain object from a Metadata message. Also converts values to other types if specified. + * @param message Metadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.DocumentSchema.Metadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; - namespace ReviewDocumentOperationMetadata { + /** + * Converts this Metadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; - /** State enum. */ - enum State { - STATE_UNSPECIFIED = 0, - RUNNING = 1, - CANCELLING = 2, - SUCCEEDED = 3, - FAILED = 4, - CANCELLED = 5 + /** + * Gets the default type url for Metadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; } } - /** Properties of a DocumentSchema. */ - interface IDocumentSchema { + /** Properties of an Evaluation. */ + interface IEvaluation { - /** DocumentSchema displayName */ - displayName?: (string|null); + /** Evaluation name */ + name?: (string|null); - /** DocumentSchema description */ - description?: (string|null); + /** Evaluation createTime */ + createTime?: (google.protobuf.ITimestamp|null); - /** DocumentSchema entityTypes */ - entityTypes?: (google.cloud.documentai.v1beta3.DocumentSchema.IEntityType[]|null); + /** Evaluation documentCounters */ + documentCounters?: (google.cloud.documentai.v1beta3.Evaluation.ICounters|null); - /** DocumentSchema metadata */ - metadata?: (google.cloud.documentai.v1beta3.DocumentSchema.IMetadata|null); + /** Evaluation allEntitiesMetrics */ + allEntitiesMetrics?: (google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics|null); + + /** Evaluation entityMetrics */ + entityMetrics?: ({ [k: string]: google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics }|null); + + /** Evaluation kmsKeyName */ + kmsKeyName?: (string|null); + + /** Evaluation kmsKeyVersionName */ + kmsKeyVersionName?: (string|null); } - /** Represents a DocumentSchema. */ - class DocumentSchema implements IDocumentSchema { + /** Represents an Evaluation. */ + class Evaluation implements IEvaluation { /** - * Constructs a new DocumentSchema. + * Constructs a new Evaluation. * @param [properties] Properties to set */ - constructor(properties?: google.cloud.documentai.v1beta3.IDocumentSchema); + constructor(properties?: google.cloud.documentai.v1beta3.IEvaluation); - /** DocumentSchema displayName. */ - public displayName: string; + /** Evaluation name. */ + public name: string; - /** DocumentSchema description. */ - public description: string; + /** Evaluation createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); - /** DocumentSchema entityTypes. */ - public entityTypes: google.cloud.documentai.v1beta3.DocumentSchema.IEntityType[]; + /** Evaluation documentCounters. */ + public documentCounters?: (google.cloud.documentai.v1beta3.Evaluation.ICounters|null); - /** DocumentSchema metadata. */ - public metadata?: (google.cloud.documentai.v1beta3.DocumentSchema.IMetadata|null); + /** Evaluation allEntitiesMetrics. */ + public allEntitiesMetrics?: (google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics|null); + + /** Evaluation entityMetrics. */ + public entityMetrics: { [k: string]: google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics }; + + /** Evaluation kmsKeyName. */ + public kmsKeyName: string; + + /** Evaluation kmsKeyVersionName. */ + public kmsKeyVersionName: string; /** - * Creates a new DocumentSchema instance using the specified properties. + * Creates a new Evaluation instance using the specified properties. * @param [properties] Properties to set - * @returns DocumentSchema instance + * @returns Evaluation instance */ - public static create(properties?: google.cloud.documentai.v1beta3.IDocumentSchema): google.cloud.documentai.v1beta3.DocumentSchema; + public static create(properties?: google.cloud.documentai.v1beta3.IEvaluation): google.cloud.documentai.v1beta3.Evaluation; /** - * Encodes the specified DocumentSchema message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.verify|verify} messages. - * @param message DocumentSchema message or plain object to encode + * Encodes the specified Evaluation message. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.verify|verify} messages. + * @param message Evaluation message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.cloud.documentai.v1beta3.IDocumentSchema, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.cloud.documentai.v1beta3.IEvaluation, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified DocumentSchema message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.verify|verify} messages. - * @param message DocumentSchema message or plain object to encode + * Encodes the specified Evaluation message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.verify|verify} messages. + * @param message Evaluation message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.cloud.documentai.v1beta3.IDocumentSchema, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.cloud.documentai.v1beta3.IEvaluation, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a DocumentSchema message from the specified reader or buffer. + * Decodes an Evaluation message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns DocumentSchema + * @returns Evaluation * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.DocumentSchema; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.Evaluation; /** - * Decodes a DocumentSchema message from the specified reader or buffer, length delimited. + * Decodes an Evaluation message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns DocumentSchema + * @returns Evaluation * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.DocumentSchema; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.Evaluation; /** - * Verifies a DocumentSchema message. + * Verifies an Evaluation message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates a DocumentSchema message from a plain object. Also converts values to their respective internal types. + * Creates an Evaluation message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns DocumentSchema + * @returns Evaluation */ - public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.DocumentSchema; + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.Evaluation; /** - * Creates a plain object from a DocumentSchema message. Also converts values to other types if specified. - * @param message DocumentSchema + * Creates a plain object from an Evaluation message. Also converts values to other types if specified. + * @param message Evaluation * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.cloud.documentai.v1beta3.DocumentSchema, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.cloud.documentai.v1beta3.Evaluation, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this DocumentSchema to JSON. + * Converts this Evaluation to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; /** - * Gets the default type url for DocumentSchema + * Gets the default type url for Evaluation * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns The default type url */ public static getTypeUrl(typeUrlPrefix?: string): string; } - namespace DocumentSchema { - - /** Properties of an EntityType. */ - interface IEntityType { + namespace Evaluation { - /** EntityType enumValues */ - enumValues?: (google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues|null); + /** Properties of a Counters. */ + interface ICounters { - /** EntityType displayName */ - displayName?: (string|null); + /** Counters inputDocumentsCount */ + inputDocumentsCount?: (number|null); - /** EntityType name */ - name?: (string|null); + /** Counters invalidDocumentsCount */ + invalidDocumentsCount?: (number|null); - /** EntityType baseTypes */ - baseTypes?: (string[]|null); + /** Counters failedDocumentsCount */ + failedDocumentsCount?: (number|null); - /** EntityType properties */ - properties?: (google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty[]|null); + /** Counters evaluatedDocumentsCount */ + evaluatedDocumentsCount?: (number|null); } - /** Represents an EntityType. */ - class EntityType implements IEntityType { + /** Represents a Counters. */ + class Counters implements ICounters { /** - * Constructs a new EntityType. + * Constructs a new Counters. * @param [properties] Properties to set */ - constructor(properties?: google.cloud.documentai.v1beta3.DocumentSchema.IEntityType); - - /** EntityType enumValues. */ - public enumValues?: (google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues|null); + constructor(properties?: google.cloud.documentai.v1beta3.Evaluation.ICounters); - /** EntityType displayName. */ - public displayName: string; - - /** EntityType name. */ - public name: string; + /** Counters inputDocumentsCount. */ + public inputDocumentsCount: number; - /** EntityType baseTypes. */ - public baseTypes: string[]; + /** Counters invalidDocumentsCount. */ + public invalidDocumentsCount: number; - /** EntityType properties. */ - public properties: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty[]; + /** Counters failedDocumentsCount. */ + public failedDocumentsCount: number; - /** EntityType valueSource. */ - public valueSource?: "enumValues"; + /** Counters evaluatedDocumentsCount. */ + public evaluatedDocumentsCount: number; /** - * Creates a new EntityType instance using the specified properties. + * Creates a new Counters instance using the specified properties. * @param [properties] Properties to set - * @returns EntityType instance + * @returns Counters instance */ - public static create(properties?: google.cloud.documentai.v1beta3.DocumentSchema.IEntityType): google.cloud.documentai.v1beta3.DocumentSchema.EntityType; + public static create(properties?: google.cloud.documentai.v1beta3.Evaluation.ICounters): google.cloud.documentai.v1beta3.Evaluation.Counters; /** - * Encodes the specified EntityType message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.verify|verify} messages. - * @param message EntityType message or plain object to encode + * Encodes the specified Counters message. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.Counters.verify|verify} messages. + * @param message Counters message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.cloud.documentai.v1beta3.DocumentSchema.IEntityType, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.cloud.documentai.v1beta3.Evaluation.ICounters, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified EntityType message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.verify|verify} messages. - * @param message EntityType message or plain object to encode + * Encodes the specified Counters message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.Counters.verify|verify} messages. + * @param message Counters message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.cloud.documentai.v1beta3.DocumentSchema.IEntityType, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.cloud.documentai.v1beta3.Evaluation.ICounters, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes an EntityType message from the specified reader or buffer. + * Decodes a Counters message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns EntityType + * @returns Counters * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.DocumentSchema.EntityType; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.Evaluation.Counters; /** - * Decodes an EntityType message from the specified reader or buffer, length delimited. + * Decodes a Counters message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns EntityType + * @returns Counters * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.DocumentSchema.EntityType; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.Evaluation.Counters; /** - * Verifies an EntityType message. + * Verifies a Counters message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates an EntityType message from a plain object. Also converts values to their respective internal types. + * Creates a Counters message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns EntityType + * @returns Counters */ - public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.DocumentSchema.EntityType; + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.Evaluation.Counters; /** - * Creates a plain object from an EntityType message. Also converts values to other types if specified. - * @param message EntityType + * Creates a plain object from a Counters message. Also converts values to other types if specified. + * @param message Counters * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.cloud.documentai.v1beta3.Evaluation.Counters, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this EntityType to JSON. + * Converts this Counters to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; /** - * Gets the default type url for EntityType + * Gets the default type url for Counters * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns The default type url */ public static getTypeUrl(typeUrlPrefix?: string): string; } - namespace EntityType { + /** Properties of a Metrics. */ + interface IMetrics { - /** Properties of an EnumValues. */ - interface IEnumValues { + /** Metrics precision */ + precision?: (number|null); - /** EnumValues values */ - values?: (string[]|null); - } + /** Metrics recall */ + recall?: (number|null); - /** Represents an EnumValues. */ - class EnumValues implements IEnumValues { + /** Metrics f1Score */ + f1Score?: (number|null); - /** - * Constructs a new EnumValues. - * @param [properties] Properties to set - */ - constructor(properties?: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues); + /** Metrics predictedOccurrencesCount */ + predictedOccurrencesCount?: (number|null); - /** EnumValues values. */ - public values: string[]; + /** Metrics groundTruthOccurrencesCount */ + groundTruthOccurrencesCount?: (number|null); - /** - * Creates a new EnumValues instance using the specified properties. - * @param [properties] Properties to set - * @returns EnumValues instance - */ - public static create(properties?: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues; + /** Metrics predictedDocumentCount */ + predictedDocumentCount?: (number|null); - /** - * Encodes the specified EnumValues message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.verify|verify} messages. - * @param message EnumValues message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues, writer?: $protobuf.Writer): $protobuf.Writer; + /** Metrics groundTruthDocumentCount */ + groundTruthDocumentCount?: (number|null); - /** - * Encodes the specified EnumValues message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.verify|verify} messages. - * @param message EnumValues message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues, writer?: $protobuf.Writer): $protobuf.Writer; + /** Metrics truePositivesCount */ + truePositivesCount?: (number|null); - /** - * Decodes an EnumValues message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns EnumValues - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues; + /** Metrics falsePositivesCount */ + falsePositivesCount?: (number|null); - /** - * Decodes an EnumValues message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns EnumValues - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues; + /** Metrics falseNegativesCount */ + falseNegativesCount?: (number|null); - /** - * Verifies an EnumValues message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); + /** Metrics totalDocumentsCount */ + totalDocumentsCount?: (number|null); + } + + /** Represents a Metrics. */ + class Metrics implements IMetrics { + + /** + * Constructs a new Metrics. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.Evaluation.IMetrics); + + /** Metrics precision. */ + public precision: number; + + /** Metrics recall. */ + public recall: number; + + /** Metrics f1Score. */ + public f1Score: number; + + /** Metrics predictedOccurrencesCount. */ + public predictedOccurrencesCount: number; + + /** Metrics groundTruthOccurrencesCount. */ + public groundTruthOccurrencesCount: number; + + /** Metrics predictedDocumentCount. */ + public predictedDocumentCount: number; + + /** Metrics groundTruthDocumentCount. */ + public groundTruthDocumentCount: number; + + /** Metrics truePositivesCount. */ + public truePositivesCount: number; + + /** Metrics falsePositivesCount. */ + public falsePositivesCount: number; + + /** Metrics falseNegativesCount. */ + public falseNegativesCount: number; + + /** Metrics totalDocumentsCount. */ + public totalDocumentsCount: number; + + /** + * Creates a new Metrics instance using the specified properties. + * @param [properties] Properties to set + * @returns Metrics instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.Evaluation.IMetrics): google.cloud.documentai.v1beta3.Evaluation.Metrics; + + /** + * Encodes the specified Metrics message. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.Metrics.verify|verify} messages. + * @param message Metrics message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.Evaluation.IMetrics, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Metrics message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.Metrics.verify|verify} messages. + * @param message Metrics message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.Evaluation.IMetrics, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Metrics message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Metrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.Evaluation.Metrics; + + /** + * Decodes a Metrics message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Metrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.Evaluation.Metrics; - /** - * Creates an EnumValues message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns EnumValues - */ - public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues; + /** + * Verifies a Metrics message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); - /** - * Creates a plain object from an EnumValues message. Also converts values to other types if specified. - * @param message EnumValues - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues, options?: $protobuf.IConversionOptions): { [k: string]: any }; + /** + * Creates a Metrics message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Metrics + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.Evaluation.Metrics; - /** - * Converts this EnumValues to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; + /** + * Creates a plain object from a Metrics message. Also converts values to other types if specified. + * @param message Metrics + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.Evaluation.Metrics, options?: $protobuf.IConversionOptions): { [k: string]: any }; - /** - * Gets the default type url for EnumValues - * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns The default type url - */ - public static getTypeUrl(typeUrlPrefix?: string): string; - } + /** + * Converts this Metrics to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; - /** Properties of a Property. */ - interface IProperty { + /** + * Gets the default type url for Metrics + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } - /** Property name */ - name?: (string|null); + /** Properties of a ConfidenceLevelMetrics. */ + interface IConfidenceLevelMetrics { - /** Property valueType */ - valueType?: (string|null); + /** ConfidenceLevelMetrics confidenceLevel */ + confidenceLevel?: (number|null); - /** Property occurrenceType */ - occurrenceType?: (google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType|keyof typeof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType|null); - } + /** ConfidenceLevelMetrics metrics */ + metrics?: (google.cloud.documentai.v1beta3.Evaluation.IMetrics|null); + } - /** Represents a Property. */ - class Property implements IProperty { + /** Represents a ConfidenceLevelMetrics. */ + class ConfidenceLevelMetrics implements IConfidenceLevelMetrics { - /** - * Constructs a new Property. - * @param [properties] Properties to set - */ - constructor(properties?: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty); + /** + * Constructs a new ConfidenceLevelMetrics. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics); - /** Property name. */ - public name: string; + /** ConfidenceLevelMetrics confidenceLevel. */ + public confidenceLevel: number; - /** Property valueType. */ - public valueType: string; + /** ConfidenceLevelMetrics metrics. */ + public metrics?: (google.cloud.documentai.v1beta3.Evaluation.IMetrics|null); - /** Property occurrenceType. */ - public occurrenceType: (google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType|keyof typeof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType); + /** + * Creates a new ConfidenceLevelMetrics instance using the specified properties. + * @param [properties] Properties to set + * @returns ConfidenceLevelMetrics instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics): google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics; - /** - * Creates a new Property instance using the specified properties. - * @param [properties] Properties to set - * @returns Property instance - */ - public static create(properties?: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property; + /** + * Encodes the specified ConfidenceLevelMetrics message. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.verify|verify} messages. + * @param message ConfidenceLevelMetrics message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics, writer?: $protobuf.Writer): $protobuf.Writer; - /** - * Encodes the specified Property message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.verify|verify} messages. - * @param message Property message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty, writer?: $protobuf.Writer): $protobuf.Writer; + /** + * Encodes the specified ConfidenceLevelMetrics message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.verify|verify} messages. + * @param message ConfidenceLevelMetrics message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics, writer?: $protobuf.Writer): $protobuf.Writer; - /** - * Encodes the specified Property message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.verify|verify} messages. - * @param message Property message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty, writer?: $protobuf.Writer): $protobuf.Writer; + /** + * Decodes a ConfidenceLevelMetrics message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ConfidenceLevelMetrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics; - /** - * Decodes a Property message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns Property - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property; + /** + * Decodes a ConfidenceLevelMetrics message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ConfidenceLevelMetrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics; - /** - * Decodes a Property message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns Property - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property; + /** + * Verifies a ConfidenceLevelMetrics message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); - /** - * Verifies a Property message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); + /** + * Creates a ConfidenceLevelMetrics message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ConfidenceLevelMetrics + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics; - /** - * Creates a Property message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns Property - */ - public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property; + /** + * Creates a plain object from a ConfidenceLevelMetrics message. Also converts values to other types if specified. + * @param message ConfidenceLevelMetrics + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics, options?: $protobuf.IConversionOptions): { [k: string]: any }; - /** - * Creates a plain object from a Property message. Also converts values to other types if specified. - * @param message Property - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property, options?: $protobuf.IConversionOptions): { [k: string]: any }; + /** + * Converts this ConfidenceLevelMetrics to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; - /** - * Converts this Property to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; + /** + * Gets the default type url for ConfidenceLevelMetrics + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } - /** - * Gets the default type url for Property - * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns The default type url - */ - public static getTypeUrl(typeUrlPrefix?: string): string; - } + /** Properties of a MultiConfidenceMetrics. */ + interface IMultiConfidenceMetrics { - namespace Property { + /** MultiConfidenceMetrics confidenceLevelMetrics */ + confidenceLevelMetrics?: (google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics[]|null); - /** OccurrenceType enum. */ - enum OccurrenceType { - OCCURRENCE_TYPE_UNSPECIFIED = 0, - OPTIONAL_ONCE = 1, - OPTIONAL_MULTIPLE = 2, - REQUIRED_ONCE = 3, - REQUIRED_MULTIPLE = 4 - } - } - } + /** MultiConfidenceMetrics confidenceLevelMetricsExact */ + confidenceLevelMetricsExact?: (google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics[]|null); - /** Properties of a Metadata. */ - interface IMetadata { + /** MultiConfidenceMetrics auprc */ + auprc?: (number|null); - /** Metadata documentSplitter */ - documentSplitter?: (boolean|null); + /** MultiConfidenceMetrics estimatedCalibrationError */ + estimatedCalibrationError?: (number|null); - /** Metadata documentAllowMultipleLabels */ - documentAllowMultipleLabels?: (boolean|null); + /** MultiConfidenceMetrics auprcExact */ + auprcExact?: (number|null); - /** Metadata prefixedNamingOnProperties */ - prefixedNamingOnProperties?: (boolean|null); + /** MultiConfidenceMetrics estimatedCalibrationErrorExact */ + estimatedCalibrationErrorExact?: (number|null); - /** Metadata skipNamingValidation */ - skipNamingValidation?: (boolean|null); + /** MultiConfidenceMetrics metricsType */ + metricsType?: (google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.MetricsType|keyof typeof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.MetricsType|null); } - /** Represents a Metadata. */ - class Metadata implements IMetadata { + /** Represents a MultiConfidenceMetrics. */ + class MultiConfidenceMetrics implements IMultiConfidenceMetrics { /** - * Constructs a new Metadata. + * Constructs a new MultiConfidenceMetrics. * @param [properties] Properties to set */ - constructor(properties?: google.cloud.documentai.v1beta3.DocumentSchema.IMetadata); + constructor(properties?: google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics); - /** Metadata documentSplitter. */ - public documentSplitter: boolean; + /** MultiConfidenceMetrics confidenceLevelMetrics. */ + public confidenceLevelMetrics: google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics[]; - /** Metadata documentAllowMultipleLabels. */ - public documentAllowMultipleLabels: boolean; + /** MultiConfidenceMetrics confidenceLevelMetricsExact. */ + public confidenceLevelMetricsExact: google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics[]; - /** Metadata prefixedNamingOnProperties. */ - public prefixedNamingOnProperties: boolean; + /** MultiConfidenceMetrics auprc. */ + public auprc: number; - /** Metadata skipNamingValidation. */ - public skipNamingValidation: boolean; + /** MultiConfidenceMetrics estimatedCalibrationError. */ + public estimatedCalibrationError: number; + + /** MultiConfidenceMetrics auprcExact. */ + public auprcExact: number; + + /** MultiConfidenceMetrics estimatedCalibrationErrorExact. */ + public estimatedCalibrationErrorExact: number; + + /** MultiConfidenceMetrics metricsType. */ + public metricsType: (google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.MetricsType|keyof typeof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.MetricsType); /** - * Creates a new Metadata instance using the specified properties. + * Creates a new MultiConfidenceMetrics instance using the specified properties. * @param [properties] Properties to set - * @returns Metadata instance + * @returns MultiConfidenceMetrics instance */ - public static create(properties?: google.cloud.documentai.v1beta3.DocumentSchema.IMetadata): google.cloud.documentai.v1beta3.DocumentSchema.Metadata; + public static create(properties?: google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics): google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics; /** - * Encodes the specified Metadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.Metadata.verify|verify} messages. - * @param message Metadata message or plain object to encode + * Encodes the specified MultiConfidenceMetrics message. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.verify|verify} messages. + * @param message MultiConfidenceMetrics message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.cloud.documentai.v1beta3.DocumentSchema.IMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified Metadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.Metadata.verify|verify} messages. - * @param message Metadata message or plain object to encode + * Encodes the specified MultiConfidenceMetrics message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.verify|verify} messages. + * @param message MultiConfidenceMetrics message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.cloud.documentai.v1beta3.DocumentSchema.IMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a Metadata message from the specified reader or buffer. + * Decodes a MultiConfidenceMetrics message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns Metadata + * @returns MultiConfidenceMetrics * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.DocumentSchema.Metadata; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics; /** - * Decodes a Metadata message from the specified reader or buffer, length delimited. + * Decodes a MultiConfidenceMetrics message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns Metadata + * @returns MultiConfidenceMetrics * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.DocumentSchema.Metadata; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics; /** - * Verifies a Metadata message. + * Verifies a MultiConfidenceMetrics message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates a Metadata message from a plain object. Also converts values to their respective internal types. + * Creates a MultiConfidenceMetrics message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns Metadata + * @returns MultiConfidenceMetrics */ - public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.DocumentSchema.Metadata; + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics; /** - * Creates a plain object from a Metadata message. Also converts values to other types if specified. - * @param message Metadata + * Creates a plain object from a MultiConfidenceMetrics message. Also converts values to other types if specified. + * @param message MultiConfidenceMetrics * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.cloud.documentai.v1beta3.DocumentSchema.Metadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this Metadata to JSON. + * Converts this MultiConfidenceMetrics to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; /** - * Gets the default type url for Metadata + * Gets the default type url for MultiConfidenceMetrics * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns The default type url */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + namespace MultiConfidenceMetrics { + + /** MetricsType enum. */ + enum MetricsType { + METRICS_TYPE_UNSPECIFIED = 0, + AGGREGATE = 1 + } + } } /** Properties of a CommonOperationMetadata. */ @@ -31424,6 +33551,9 @@ export namespace google { /** ProcessorVersion displayName */ displayName?: (string|null); + /** ProcessorVersion documentSchema */ + documentSchema?: (google.cloud.documentai.v1beta3.IDocumentSchema|null); + /** ProcessorVersion state */ state?: (google.cloud.documentai.v1beta3.ProcessorVersion.State|keyof typeof google.cloud.documentai.v1beta3.ProcessorVersion.State|null); @@ -31458,6 +33588,9 @@ export namespace google { /** ProcessorVersion displayName. */ public displayName: string; + /** ProcessorVersion documentSchema. */ + public documentSchema?: (google.cloud.documentai.v1beta3.IDocumentSchema|null); + /** ProcessorVersion state. */ public state: (google.cloud.documentai.v1beta3.ProcessorVersion.State|keyof typeof google.cloud.documentai.v1beta3.ProcessorVersion.State); diff --git a/packages/google-cloud-documentai/protos/protos.js b/packages/google-cloud-documentai/protos/protos.js index 3a0d67dc16f..ee6e3946501 100644 --- a/packages/google-cloud-documentai/protos/protos.js +++ b/packages/google-cloud-documentai/protos/protos.js @@ -52665,6 +52665,7 @@ * @property {string|null} [textStyle] Style textStyle * @property {string|null} [textDecoration] Style textDecoration * @property {google.cloud.documentai.v1beta3.Document.Style.IFontSize|null} [fontSize] Style fontSize + * @property {string|null} [fontFamily] Style fontFamily */ /** @@ -52738,6 +52739,14 @@ */ Style.prototype.fontSize = null; + /** + * Style fontFamily. + * @member {string} fontFamily + * @memberof google.cloud.documentai.v1beta3.Document.Style + * @instance + */ + Style.prototype.fontFamily = ""; + /** * Creates a new Style instance using the specified properties. * @function create @@ -52776,6 +52785,8 @@ writer.uint32(/* id 6, wireType 2 =*/50).string(message.textDecoration); if (message.fontSize != null && Object.hasOwnProperty.call(message, "fontSize")) $root.google.cloud.documentai.v1beta3.Document.Style.FontSize.encode(message.fontSize, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.fontFamily != null && Object.hasOwnProperty.call(message, "fontFamily")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.fontFamily); return writer; }; @@ -52838,6 +52849,10 @@ message.fontSize = $root.google.cloud.documentai.v1beta3.Document.Style.FontSize.decode(reader, reader.uint32()); break; } + case 8: { + message.fontFamily = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -52902,6 +52917,9 @@ if (error) return "fontSize." + error; } + if (message.fontFamily != null && message.hasOwnProperty("fontFamily")) + if (!$util.isString(message.fontFamily)) + return "fontFamily: string expected"; return null; }; @@ -52943,6 +52961,8 @@ throw TypeError(".google.cloud.documentai.v1beta3.Document.Style.fontSize: object expected"); message.fontSize = $root.google.cloud.documentai.v1beta3.Document.Style.FontSize.fromObject(object.fontSize); } + if (object.fontFamily != null) + message.fontFamily = String(object.fontFamily); return message; }; @@ -52967,6 +52987,7 @@ object.textStyle = ""; object.textDecoration = ""; object.fontSize = null; + object.fontFamily = ""; } if (message.textAnchor != null && message.hasOwnProperty("textAnchor")) object.textAnchor = $root.google.cloud.documentai.v1beta3.Document.TextAnchor.toObject(message.textAnchor, options); @@ -52982,6 +53003,8 @@ object.textDecoration = message.textDecoration; if (message.fontSize != null && message.hasOwnProperty("fontSize")) object.fontSize = $root.google.cloud.documentai.v1beta3.Document.Style.FontSize.toObject(message.fontSize, options); + if (message.fontFamily != null && message.hasOwnProperty("fontFamily")) + object.fontFamily = message.fontFamily; return object; }; @@ -53262,6 +53285,7 @@ * @property {Array.|null} [formFields] Page formFields * @property {Array.|null} [symbols] Page symbols * @property {Array.|null} [detectedBarcodes] Page detectedBarcodes + * @property {google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores|null} [imageQualityScores] Page imageQualityScores * @property {google.cloud.documentai.v1beta3.Document.IProvenance|null} [provenance] Page provenance */ @@ -53411,6 +53435,14 @@ */ Page.prototype.detectedBarcodes = $util.emptyArray; + /** + * Page imageQualityScores. + * @member {google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores|null|undefined} imageQualityScores + * @memberof google.cloud.documentai.v1beta3.Document.Page + * @instance + */ + Page.prototype.imageQualityScores = null; + /** * Page provenance. * @member {google.cloud.documentai.v1beta3.Document.IProvenance|null|undefined} provenance @@ -53486,6 +53518,8 @@ $root.google.cloud.documentai.v1beta3.Document.Page.DetectedBarcode.encode(message.detectedBarcodes[i], writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim(); if (message.provenance != null && Object.hasOwnProperty.call(message, "provenance")) $root.google.cloud.documentai.v1beta3.Document.Provenance.encode(message.provenance, writer.uint32(/* id 16, wireType 2 =*/130).fork()).ldelim(); + if (message.imageQualityScores != null && Object.hasOwnProperty.call(message, "imageQualityScores")) + $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.encode(message.imageQualityScores, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim(); return writer; }; @@ -53602,6 +53636,10 @@ message.detectedBarcodes.push($root.google.cloud.documentai.v1beta3.Document.Page.DetectedBarcode.decode(reader, reader.uint32())); break; } + case 17: { + message.imageQualityScores = $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.decode(reader, reader.uint32()); + break; + } case 16: { message.provenance = $root.google.cloud.documentai.v1beta3.Document.Provenance.decode(reader, reader.uint32()); break; @@ -53758,6 +53796,11 @@ return "detectedBarcodes." + error; } } + if (message.imageQualityScores != null && message.hasOwnProperty("imageQualityScores")) { + var error = $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.verify(message.imageQualityScores); + if (error) + return "imageQualityScores." + error; + } if (message.provenance != null && message.hasOwnProperty("provenance")) { var error = $root.google.cloud.documentai.v1beta3.Document.Provenance.verify(message.provenance); if (error) @@ -53905,6 +53948,11 @@ message.detectedBarcodes[i] = $root.google.cloud.documentai.v1beta3.Document.Page.DetectedBarcode.fromObject(object.detectedBarcodes[i]); } } + if (object.imageQualityScores != null) { + if (typeof object.imageQualityScores !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Document.Page.imageQualityScores: object expected"); + message.imageQualityScores = $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.fromObject(object.imageQualityScores); + } if (object.provenance != null) { if (typeof object.provenance !== "object") throw TypeError(".google.cloud.documentai.v1beta3.Document.Page.provenance: object expected"); @@ -53945,6 +53993,7 @@ object.layout = null; object.image = null; object.provenance = null; + object.imageQualityScores = null; } if (message.pageNumber != null && message.hasOwnProperty("pageNumber")) object.pageNumber = message.pageNumber; @@ -54011,6 +54060,8 @@ } if (message.provenance != null && message.hasOwnProperty("provenance")) object.provenance = $root.google.cloud.documentai.v1beta3.Document.Provenance.toObject(message.provenance, options); + if (message.imageQualityScores != null && message.hasOwnProperty("imageQualityScores")) + object.imageQualityScores = $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.toObject(message.imageQualityScores, options); return object; }; @@ -57137,6 +57188,7 @@ * @property {Array.|null} [headerRows] Table headerRows * @property {Array.|null} [bodyRows] Table bodyRows * @property {Array.|null} [detectedLanguages] Table detectedLanguages + * @property {google.cloud.documentai.v1beta3.Document.IProvenance|null} [provenance] Table provenance */ /** @@ -57189,6 +57241,14 @@ */ Table.prototype.detectedLanguages = $util.emptyArray; + /** + * Table provenance. + * @member {google.cloud.documentai.v1beta3.Document.IProvenance|null|undefined} provenance + * @memberof google.cloud.documentai.v1beta3.Document.Page.Table + * @instance + */ + Table.prototype.provenance = null; + /** * Creates a new Table instance using the specified properties. * @function create @@ -57224,6 +57284,8 @@ if (message.detectedLanguages != null && message.detectedLanguages.length) for (var i = 0; i < message.detectedLanguages.length; ++i) $root.google.cloud.documentai.v1beta3.Document.Page.DetectedLanguage.encode(message.detectedLanguages[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.provenance != null && Object.hasOwnProperty.call(message, "provenance")) + $root.google.cloud.documentai.v1beta3.Document.Provenance.encode(message.provenance, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -57280,6 +57342,10 @@ message.detectedLanguages.push($root.google.cloud.documentai.v1beta3.Document.Page.DetectedLanguage.decode(reader, reader.uint32())); break; } + case 5: { + message.provenance = $root.google.cloud.documentai.v1beta3.Document.Provenance.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -57347,6 +57413,11 @@ return "detectedLanguages." + error; } } + if (message.provenance != null && message.hasOwnProperty("provenance")) { + var error = $root.google.cloud.documentai.v1beta3.Document.Provenance.verify(message.provenance); + if (error) + return "provenance." + error; + } return null; }; @@ -57397,6 +57468,11 @@ message.detectedLanguages[i] = $root.google.cloud.documentai.v1beta3.Document.Page.DetectedLanguage.fromObject(object.detectedLanguages[i]); } } + if (object.provenance != null) { + if (typeof object.provenance !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Document.Page.Table.provenance: object expected"); + message.provenance = $root.google.cloud.documentai.v1beta3.Document.Provenance.fromObject(object.provenance); + } return message; }; @@ -57418,8 +57494,10 @@ object.bodyRows = []; object.detectedLanguages = []; } - if (options.defaults) + if (options.defaults) { object.layout = null; + object.provenance = null; + } if (message.layout != null && message.hasOwnProperty("layout")) object.layout = $root.google.cloud.documentai.v1beta3.Document.Page.Layout.toObject(message.layout, options); if (message.headerRows && message.headerRows.length) { @@ -57437,6 +57515,8 @@ for (var j = 0; j < message.detectedLanguages.length; ++j) object.detectedLanguages[j] = $root.google.cloud.documentai.v1beta3.Document.Page.DetectedLanguage.toObject(message.detectedLanguages[j], options); } + if (message.provenance != null && message.hasOwnProperty("provenance")) + object.provenance = $root.google.cloud.documentai.v1beta3.Document.Provenance.toObject(message.provenance, options); return object; }; @@ -58881,297 +58961,772 @@ return DetectedLanguage; })(); - return Page; - })(); + Page.ImageQualityScores = (function() { - Document.Entity = (function() { + /** + * Properties of an ImageQualityScores. + * @memberof google.cloud.documentai.v1beta3.Document.Page + * @interface IImageQualityScores + * @property {number|null} [qualityScore] ImageQualityScores qualityScore + * @property {Array.|null} [detectedDefects] ImageQualityScores detectedDefects + */ - /** - * Properties of an Entity. - * @memberof google.cloud.documentai.v1beta3.Document - * @interface IEntity - * @property {google.cloud.documentai.v1beta3.Document.ITextAnchor|null} [textAnchor] Entity textAnchor - * @property {string|null} [type] Entity type - * @property {string|null} [mentionText] Entity mentionText - * @property {string|null} [mentionId] Entity mentionId - * @property {number|null} [confidence] Entity confidence - * @property {google.cloud.documentai.v1beta3.Document.IPageAnchor|null} [pageAnchor] Entity pageAnchor - * @property {string|null} [id] Entity id - * @property {google.cloud.documentai.v1beta3.Document.Entity.INormalizedValue|null} [normalizedValue] Entity normalizedValue - * @property {Array.|null} [properties] Entity properties - * @property {google.cloud.documentai.v1beta3.Document.IProvenance|null} [provenance] Entity provenance - * @property {boolean|null} [redacted] Entity redacted - */ + /** + * Constructs a new ImageQualityScores. + * @memberof google.cloud.documentai.v1beta3.Document.Page + * @classdesc Represents an ImageQualityScores. + * @implements IImageQualityScores + * @constructor + * @param {google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores=} [properties] Properties to set + */ + function ImageQualityScores(properties) { + this.detectedDefects = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } - /** - * Constructs a new Entity. - * @memberof google.cloud.documentai.v1beta3.Document - * @classdesc Represents an Entity. - * @implements IEntity - * @constructor - * @param {google.cloud.documentai.v1beta3.Document.IEntity=} [properties] Properties to set - */ - function Entity(properties) { - this.properties = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + /** + * ImageQualityScores qualityScore. + * @member {number} qualityScore + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @instance + */ + ImageQualityScores.prototype.qualityScore = 0; - /** - * Entity textAnchor. - * @member {google.cloud.documentai.v1beta3.Document.ITextAnchor|null|undefined} textAnchor - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.textAnchor = null; + /** + * ImageQualityScores detectedDefects. + * @member {Array.} detectedDefects + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @instance + */ + ImageQualityScores.prototype.detectedDefects = $util.emptyArray; - /** - * Entity type. - * @member {string} type - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.type = ""; + /** + * Creates a new ImageQualityScores instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @static + * @param {google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores} ImageQualityScores instance + */ + ImageQualityScores.create = function create(properties) { + return new ImageQualityScores(properties); + }; - /** - * Entity mentionText. - * @member {string} mentionText - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.mentionText = ""; + /** + * Encodes the specified ImageQualityScores message. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @static + * @param {google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores} message ImageQualityScores message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImageQualityScores.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.qualityScore != null && Object.hasOwnProperty.call(message, "qualityScore")) + writer.uint32(/* id 1, wireType 5 =*/13).float(message.qualityScore); + if (message.detectedDefects != null && message.detectedDefects.length) + for (var i = 0; i < message.detectedDefects.length; ++i) + $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect.encode(message.detectedDefects[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; - /** - * Entity mentionId. - * @member {string} mentionId - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.mentionId = ""; + /** + * Encodes the specified ImageQualityScores message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @static + * @param {google.cloud.documentai.v1beta3.Document.Page.IImageQualityScores} message ImageQualityScores message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImageQualityScores.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; - /** - * Entity confidence. - * @member {number} confidence - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.confidence = 0; + /** + * Decodes an ImageQualityScores message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores} ImageQualityScores + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImageQualityScores.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.qualityScore = reader.float(); + break; + } + case 2: { + if (!(message.detectedDefects && message.detectedDefects.length)) + message.detectedDefects = []; + message.detectedDefects.push($root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; - /** - * Entity pageAnchor. - * @member {google.cloud.documentai.v1beta3.Document.IPageAnchor|null|undefined} pageAnchor - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.pageAnchor = null; + /** + * Decodes an ImageQualityScores message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores} ImageQualityScores + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImageQualityScores.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; - /** - * Entity id. - * @member {string} id - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.id = ""; + /** + * Verifies an ImageQualityScores message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImageQualityScores.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.qualityScore != null && message.hasOwnProperty("qualityScore")) + if (typeof message.qualityScore !== "number") + return "qualityScore: number expected"; + if (message.detectedDefects != null && message.hasOwnProperty("detectedDefects")) { + if (!Array.isArray(message.detectedDefects)) + return "detectedDefects: array expected"; + for (var i = 0; i < message.detectedDefects.length; ++i) { + var error = $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect.verify(message.detectedDefects[i]); + if (error) + return "detectedDefects." + error; + } + } + return null; + }; - /** - * Entity normalizedValue. - * @member {google.cloud.documentai.v1beta3.Document.Entity.INormalizedValue|null|undefined} normalizedValue - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.normalizedValue = null; + /** + * Creates an ImageQualityScores message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores} ImageQualityScores + */ + ImageQualityScores.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores) + return object; + var message = new $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores(); + if (object.qualityScore != null) + message.qualityScore = Number(object.qualityScore); + if (object.detectedDefects) { + if (!Array.isArray(object.detectedDefects)) + throw TypeError(".google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.detectedDefects: array expected"); + message.detectedDefects = []; + for (var i = 0; i < object.detectedDefects.length; ++i) { + if (typeof object.detectedDefects[i] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.detectedDefects: object expected"); + message.detectedDefects[i] = $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect.fromObject(object.detectedDefects[i]); + } + } + return message; + }; - /** - * Entity properties. - * @member {Array.} properties - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.properties = $util.emptyArray; + /** + * Creates a plain object from an ImageQualityScores message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @static + * @param {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores} message ImageQualityScores + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImageQualityScores.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.detectedDefects = []; + if (options.defaults) + object.qualityScore = 0; + if (message.qualityScore != null && message.hasOwnProperty("qualityScore")) + object.qualityScore = options.json && !isFinite(message.qualityScore) ? String(message.qualityScore) : message.qualityScore; + if (message.detectedDefects && message.detectedDefects.length) { + object.detectedDefects = []; + for (var j = 0; j < message.detectedDefects.length; ++j) + object.detectedDefects[j] = $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect.toObject(message.detectedDefects[j], options); + } + return object; + }; - /** - * Entity provenance. - * @member {google.cloud.documentai.v1beta3.Document.IProvenance|null|undefined} provenance - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.provenance = null; + /** + * Converts this ImageQualityScores to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @instance + * @returns {Object.} JSON object + */ + ImageQualityScores.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; - /** - * Entity redacted. - * @member {boolean} redacted - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @instance - */ - Entity.prototype.redacted = false; + /** + * Gets the default type url for ImageQualityScores + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImageQualityScores.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores"; + }; - /** - * Creates a new Entity instance using the specified properties. - * @function create - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @static - * @param {google.cloud.documentai.v1beta3.Document.IEntity=} [properties] Properties to set - * @returns {google.cloud.documentai.v1beta3.Document.Entity} Entity instance - */ - Entity.create = function create(properties) { - return new Entity(properties); - }; + ImageQualityScores.DetectedDefect = (function() { - /** - * Encodes the specified Entity message. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Entity.verify|verify} messages. - * @function encode - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @static - * @param {google.cloud.documentai.v1beta3.Document.IEntity} message Entity message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Entity.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.textAnchor != null && Object.hasOwnProperty.call(message, "textAnchor")) - $root.google.cloud.documentai.v1beta3.Document.TextAnchor.encode(message.textAnchor, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.type != null && Object.hasOwnProperty.call(message, "type")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.type); - if (message.mentionText != null && Object.hasOwnProperty.call(message, "mentionText")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.mentionText); - if (message.mentionId != null && Object.hasOwnProperty.call(message, "mentionId")) - writer.uint32(/* id 4, wireType 2 =*/34).string(message.mentionId); - if (message.confidence != null && Object.hasOwnProperty.call(message, "confidence")) - writer.uint32(/* id 5, wireType 5 =*/45).float(message.confidence); - if (message.pageAnchor != null && Object.hasOwnProperty.call(message, "pageAnchor")) - $root.google.cloud.documentai.v1beta3.Document.PageAnchor.encode(message.pageAnchor, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); - if (message.id != null && Object.hasOwnProperty.call(message, "id")) - writer.uint32(/* id 7, wireType 2 =*/58).string(message.id); - if (message.normalizedValue != null && Object.hasOwnProperty.call(message, "normalizedValue")) - $root.google.cloud.documentai.v1beta3.Document.Entity.NormalizedValue.encode(message.normalizedValue, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); - if (message.properties != null && message.properties.length) - for (var i = 0; i < message.properties.length; ++i) - $root.google.cloud.documentai.v1beta3.Document.Entity.encode(message.properties[i], writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); - if (message.provenance != null && Object.hasOwnProperty.call(message, "provenance")) - $root.google.cloud.documentai.v1beta3.Document.Provenance.encode(message.provenance, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); - if (message.redacted != null && Object.hasOwnProperty.call(message, "redacted")) - writer.uint32(/* id 12, wireType 0 =*/96).bool(message.redacted); - return writer; - }; + /** + * Properties of a DetectedDefect. + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @interface IDetectedDefect + * @property {string|null} [type] DetectedDefect type + * @property {number|null} [confidence] DetectedDefect confidence + */ - /** - * Encodes the specified Entity message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Entity.verify|verify} messages. - * @function encodeDelimited - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @static - * @param {google.cloud.documentai.v1beta3.Document.IEntity} message Entity message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Entity.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + /** + * Constructs a new DetectedDefect. + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores + * @classdesc Represents a DetectedDefect. + * @implements IDetectedDefect + * @constructor + * @param {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.IDetectedDefect=} [properties] Properties to set + */ + function DetectedDefect(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } - /** - * Decodes an Entity message from the specified reader or buffer. - * @function decode - * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.documentai.v1beta3.Document.Entity} Entity - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Entity.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Document.Entity(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: { - message.textAnchor = $root.google.cloud.documentai.v1beta3.Document.TextAnchor.decode(reader, reader.uint32()); - break; - } - case 2: { - message.type = reader.string(); - break; - } - case 3: { - message.mentionText = reader.string(); - break; - } - case 4: { - message.mentionId = reader.string(); - break; - } - case 5: { - message.confidence = reader.float(); - break; - } - case 6: { - message.pageAnchor = $root.google.cloud.documentai.v1beta3.Document.PageAnchor.decode(reader, reader.uint32()); - break; - } - case 7: { - message.id = reader.string(); - break; - } - case 9: { - message.normalizedValue = $root.google.cloud.documentai.v1beta3.Document.Entity.NormalizedValue.decode(reader, reader.uint32()); - break; - } - case 10: { - if (!(message.properties && message.properties.length)) - message.properties = []; - message.properties.push($root.google.cloud.documentai.v1beta3.Document.Entity.decode(reader, reader.uint32())); - break; - } - case 11: { - message.provenance = $root.google.cloud.documentai.v1beta3.Document.Provenance.decode(reader, reader.uint32()); - break; + /** + * DetectedDefect type. + * @member {string} type + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @instance + */ + DetectedDefect.prototype.type = ""; + + /** + * DetectedDefect confidence. + * @member {number} confidence + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @instance + */ + DetectedDefect.prototype.confidence = 0; + + /** + * Creates a new DetectedDefect instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @static + * @param {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.IDetectedDefect=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect} DetectedDefect instance + */ + DetectedDefect.create = function create(properties) { + return new DetectedDefect(properties); + }; + + /** + * Encodes the specified DetectedDefect message. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @static + * @param {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.IDetectedDefect} message DetectedDefect message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DetectedDefect.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.type); + if (message.confidence != null && Object.hasOwnProperty.call(message, "confidence")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.confidence); + return writer; + }; + + /** + * Encodes the specified DetectedDefect message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @static + * @param {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.IDetectedDefect} message DetectedDefect message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DetectedDefect.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DetectedDefect message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect} DetectedDefect + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DetectedDefect.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.string(); + break; + } + case 2: { + message.confidence = reader.float(); + break; + } + default: + reader.skipType(tag & 7); + break; + } } - case 12: { - message.redacted = reader.bool(); - break; + return message; + }; + + /** + * Decodes a DetectedDefect message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect} DetectedDefect + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DetectedDefect.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DetectedDefect message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DetectedDefect.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.confidence != null && message.hasOwnProperty("confidence")) + if (typeof message.confidence !== "number") + return "confidence: number expected"; + return null; + }; + + /** + * Creates a DetectedDefect message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect} DetectedDefect + */ + DetectedDefect.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect) + return object; + var message = new $root.google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect(); + if (object.type != null) + message.type = String(object.type); + if (object.confidence != null) + message.confidence = Number(object.confidence); + return message; + }; + + /** + * Creates a plain object from a DetectedDefect message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @static + * @param {google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect} message DetectedDefect + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DetectedDefect.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type = ""; + object.confidence = 0; } - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.confidence != null && message.hasOwnProperty("confidence")) + object.confidence = options.json && !isFinite(message.confidence) ? String(message.confidence) : message.confidence; + return object; + }; + + /** + * Converts this DetectedDefect to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @instance + * @returns {Object.} JSON object + */ + DetectedDefect.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DetectedDefect + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DetectedDefect.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.Document.Page.ImageQualityScores.DetectedDefect"; + }; + + return DetectedDefect; + })(); + + return ImageQualityScores; + })(); + + return Page; + })(); + + Document.Entity = (function() { /** - * Decodes an Entity message from the specified reader or buffer, length delimited. - * @function decodeDelimited + * Properties of an Entity. + * @memberof google.cloud.documentai.v1beta3.Document + * @interface IEntity + * @property {google.cloud.documentai.v1beta3.Document.ITextAnchor|null} [textAnchor] Entity textAnchor + * @property {string|null} [type] Entity type + * @property {string|null} [mentionText] Entity mentionText + * @property {string|null} [mentionId] Entity mentionId + * @property {number|null} [confidence] Entity confidence + * @property {google.cloud.documentai.v1beta3.Document.IPageAnchor|null} [pageAnchor] Entity pageAnchor + * @property {string|null} [id] Entity id + * @property {google.cloud.documentai.v1beta3.Document.Entity.INormalizedValue|null} [normalizedValue] Entity normalizedValue + * @property {Array.|null} [properties] Entity properties + * @property {google.cloud.documentai.v1beta3.Document.IProvenance|null} [provenance] Entity provenance + * @property {boolean|null} [redacted] Entity redacted + */ + + /** + * Constructs a new Entity. + * @memberof google.cloud.documentai.v1beta3.Document + * @classdesc Represents an Entity. + * @implements IEntity + * @constructor + * @param {google.cloud.documentai.v1beta3.Document.IEntity=} [properties] Properties to set + */ + function Entity(properties) { + this.properties = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Entity textAnchor. + * @member {google.cloud.documentai.v1beta3.Document.ITextAnchor|null|undefined} textAnchor * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.documentai.v1beta3.Document.Entity} Entity - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing + * @instance */ - Entity.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + Entity.prototype.textAnchor = null; /** - * Verifies an Entity message. - * @function verify + * Entity type. + * @member {string} type * @memberof google.cloud.documentai.v1beta3.Document.Entity - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not + * @instance */ - Entity.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.textAnchor != null && message.hasOwnProperty("textAnchor")) { - var error = $root.google.cloud.documentai.v1beta3.Document.TextAnchor.verify(message.textAnchor); - if (error) + Entity.prototype.type = ""; + + /** + * Entity mentionText. + * @member {string} mentionText + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @instance + */ + Entity.prototype.mentionText = ""; + + /** + * Entity mentionId. + * @member {string} mentionId + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @instance + */ + Entity.prototype.mentionId = ""; + + /** + * Entity confidence. + * @member {number} confidence + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @instance + */ + Entity.prototype.confidence = 0; + + /** + * Entity pageAnchor. + * @member {google.cloud.documentai.v1beta3.Document.IPageAnchor|null|undefined} pageAnchor + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @instance + */ + Entity.prototype.pageAnchor = null; + + /** + * Entity id. + * @member {string} id + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @instance + */ + Entity.prototype.id = ""; + + /** + * Entity normalizedValue. + * @member {google.cloud.documentai.v1beta3.Document.Entity.INormalizedValue|null|undefined} normalizedValue + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @instance + */ + Entity.prototype.normalizedValue = null; + + /** + * Entity properties. + * @member {Array.} properties + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @instance + */ + Entity.prototype.properties = $util.emptyArray; + + /** + * Entity provenance. + * @member {google.cloud.documentai.v1beta3.Document.IProvenance|null|undefined} provenance + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @instance + */ + Entity.prototype.provenance = null; + + /** + * Entity redacted. + * @member {boolean} redacted + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @instance + */ + Entity.prototype.redacted = false; + + /** + * Creates a new Entity instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @static + * @param {google.cloud.documentai.v1beta3.Document.IEntity=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.Document.Entity} Entity instance + */ + Entity.create = function create(properties) { + return new Entity(properties); + }; + + /** + * Encodes the specified Entity message. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Entity.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @static + * @param {google.cloud.documentai.v1beta3.Document.IEntity} message Entity message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Entity.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.textAnchor != null && Object.hasOwnProperty.call(message, "textAnchor")) + $root.google.cloud.documentai.v1beta3.Document.TextAnchor.encode(message.textAnchor, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.type); + if (message.mentionText != null && Object.hasOwnProperty.call(message, "mentionText")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.mentionText); + if (message.mentionId != null && Object.hasOwnProperty.call(message, "mentionId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.mentionId); + if (message.confidence != null && Object.hasOwnProperty.call(message, "confidence")) + writer.uint32(/* id 5, wireType 5 =*/45).float(message.confidence); + if (message.pageAnchor != null && Object.hasOwnProperty.call(message, "pageAnchor")) + $root.google.cloud.documentai.v1beta3.Document.PageAnchor.encode(message.pageAnchor, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.id); + if (message.normalizedValue != null && Object.hasOwnProperty.call(message, "normalizedValue")) + $root.google.cloud.documentai.v1beta3.Document.Entity.NormalizedValue.encode(message.normalizedValue, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.properties != null && message.properties.length) + for (var i = 0; i < message.properties.length; ++i) + $root.google.cloud.documentai.v1beta3.Document.Entity.encode(message.properties[i], writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.provenance != null && Object.hasOwnProperty.call(message, "provenance")) + $root.google.cloud.documentai.v1beta3.Document.Provenance.encode(message.provenance, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.redacted != null && Object.hasOwnProperty.call(message, "redacted")) + writer.uint32(/* id 12, wireType 0 =*/96).bool(message.redacted); + return writer; + }; + + /** + * Encodes the specified Entity message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.Entity.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @static + * @param {google.cloud.documentai.v1beta3.Document.IEntity} message Entity message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Entity.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Entity message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.Document.Entity} Entity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Entity.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Document.Entity(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.textAnchor = $root.google.cloud.documentai.v1beta3.Document.TextAnchor.decode(reader, reader.uint32()); + break; + } + case 2: { + message.type = reader.string(); + break; + } + case 3: { + message.mentionText = reader.string(); + break; + } + case 4: { + message.mentionId = reader.string(); + break; + } + case 5: { + message.confidence = reader.float(); + break; + } + case 6: { + message.pageAnchor = $root.google.cloud.documentai.v1beta3.Document.PageAnchor.decode(reader, reader.uint32()); + break; + } + case 7: { + message.id = reader.string(); + break; + } + case 9: { + message.normalizedValue = $root.google.cloud.documentai.v1beta3.Document.Entity.NormalizedValue.decode(reader, reader.uint32()); + break; + } + case 10: { + if (!(message.properties && message.properties.length)) + message.properties = []; + message.properties.push($root.google.cloud.documentai.v1beta3.Document.Entity.decode(reader, reader.uint32())); + break; + } + case 11: { + message.provenance = $root.google.cloud.documentai.v1beta3.Document.Provenance.decode(reader, reader.uint32()); + break; + } + case 12: { + message.redacted = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Entity message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.Document.Entity} Entity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Entity.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Entity message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.Document.Entity + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Entity.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.textAnchor != null && message.hasOwnProperty("textAnchor")) { + var error = $root.google.cloud.documentai.v1beta3.Document.TextAnchor.verify(message.textAnchor); + if (error) return "textAnchor." + error; } if (message.type != null && message.hasOwnProperty("type")) @@ -64815,6 +65370,7 @@ * @memberof google.cloud.documentai.v1beta3.DocumentOutputConfig * @interface IGcsOutputConfig * @property {string|null} [gcsUri] GcsOutputConfig gcsUri + * @property {google.protobuf.IFieldMask|null} [fieldMask] GcsOutputConfig fieldMask */ /** @@ -64840,6 +65396,14 @@ */ GcsOutputConfig.prototype.gcsUri = ""; + /** + * GcsOutputConfig fieldMask. + * @member {google.protobuf.IFieldMask|null|undefined} fieldMask + * @memberof google.cloud.documentai.v1beta3.DocumentOutputConfig.GcsOutputConfig + * @instance + */ + GcsOutputConfig.prototype.fieldMask = null; + /** * Creates a new GcsOutputConfig instance using the specified properties. * @function create @@ -64866,6 +65430,8 @@ writer = $Writer.create(); if (message.gcsUri != null && Object.hasOwnProperty.call(message, "gcsUri")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.gcsUri); + if (message.fieldMask != null && Object.hasOwnProperty.call(message, "fieldMask")) + $root.google.protobuf.FieldMask.encode(message.fieldMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -64904,6 +65470,10 @@ message.gcsUri = reader.string(); break; } + case 2: { + message.fieldMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -64942,8 +65512,13 @@ if (message.gcsUri != null && message.hasOwnProperty("gcsUri")) if (!$util.isString(message.gcsUri)) return "gcsUri: string expected"; - return null; - }; + if (message.fieldMask != null && message.hasOwnProperty("fieldMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.fieldMask); + if (error) + return "fieldMask." + error; + } + return null; + }; /** * Creates a GcsOutputConfig message from a plain object. Also converts values to their respective internal types. @@ -64959,6 +65534,11 @@ var message = new $root.google.cloud.documentai.v1beta3.DocumentOutputConfig.GcsOutputConfig(); if (object.gcsUri != null) message.gcsUri = String(object.gcsUri); + if (object.fieldMask != null) { + if (typeof object.fieldMask !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.DocumentOutputConfig.GcsOutputConfig.fieldMask: object expected"); + message.fieldMask = $root.google.protobuf.FieldMask.fromObject(object.fieldMask); + } return message; }; @@ -64975,10 +65555,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.gcsUri = ""; + object.fieldMask = null; + } if (message.gcsUri != null && message.hasOwnProperty("gcsUri")) object.gcsUri = message.gcsUri; + if (message.fieldMask != null && message.hasOwnProperty("fieldMask")) + object.fieldMask = $root.google.protobuf.FieldMask.toObject(message.fieldMask, options); return object; }; @@ -65244,6 +65828,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|trainProcessorVersion}. + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @typedef TrainProcessorVersionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls TrainProcessorVersion. + * @function trainProcessorVersion + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @instance + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest} request TrainProcessorVersionRequest message or plain object + * @param {google.cloud.documentai.v1beta3.DocumentProcessorService.TrainProcessorVersionCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DocumentProcessorService.prototype.trainProcessorVersion = function trainProcessorVersion(request, callback) { + return this.rpcCall(trainProcessorVersion, $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "TrainProcessorVersion" }); + + /** + * Calls TrainProcessorVersion. + * @function trainProcessorVersion + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @instance + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest} request TrainProcessorVersionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|getProcessorVersion}. * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService @@ -65607,6 +66224,105 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|evaluateProcessorVersion}. + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @typedef EvaluateProcessorVersionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls EvaluateProcessorVersion. + * @function evaluateProcessorVersion + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @instance + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest} request EvaluateProcessorVersionRequest message or plain object + * @param {google.cloud.documentai.v1beta3.DocumentProcessorService.EvaluateProcessorVersionCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DocumentProcessorService.prototype.evaluateProcessorVersion = function evaluateProcessorVersion(request, callback) { + return this.rpcCall(evaluateProcessorVersion, $root.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "EvaluateProcessorVersion" }); + + /** + * Calls EvaluateProcessorVersion. + * @function evaluateProcessorVersion + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @instance + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest} request EvaluateProcessorVersionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|getEvaluation}. + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @typedef GetEvaluationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.documentai.v1beta3.Evaluation} [response] Evaluation + */ + + /** + * Calls GetEvaluation. + * @function getEvaluation + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @instance + * @param {google.cloud.documentai.v1beta3.IGetEvaluationRequest} request GetEvaluationRequest message or plain object + * @param {google.cloud.documentai.v1beta3.DocumentProcessorService.GetEvaluationCallback} callback Node-style callback called with the error, if any, and Evaluation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DocumentProcessorService.prototype.getEvaluation = function getEvaluation(request, callback) { + return this.rpcCall(getEvaluation, $root.google.cloud.documentai.v1beta3.GetEvaluationRequest, $root.google.cloud.documentai.v1beta3.Evaluation, request, callback); + }, "name", { value: "GetEvaluation" }); + + /** + * Calls GetEvaluation. + * @function getEvaluation + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @instance + * @param {google.cloud.documentai.v1beta3.IGetEvaluationRequest} request GetEvaluationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.documentai.v1beta3.DocumentProcessorService|listEvaluations}. + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @typedef ListEvaluationsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.documentai.v1beta3.ListEvaluationsResponse} [response] ListEvaluationsResponse + */ + + /** + * Calls ListEvaluations. + * @function listEvaluations + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @instance + * @param {google.cloud.documentai.v1beta3.IListEvaluationsRequest} request ListEvaluationsRequest message or plain object + * @param {google.cloud.documentai.v1beta3.DocumentProcessorService.ListEvaluationsCallback} callback Node-style callback called with the error, if any, and ListEvaluationsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DocumentProcessorService.prototype.listEvaluations = function listEvaluations(request, callback) { + return this.rpcCall(listEvaluations, $root.google.cloud.documentai.v1beta3.ListEvaluationsRequest, $root.google.cloud.documentai.v1beta3.ListEvaluationsResponse, request, callback); + }, "name", { value: "ListEvaluations" }); + + /** + * Calls ListEvaluations. + * @function listEvaluations + * @memberof google.cloud.documentai.v1beta3.DocumentProcessorService + * @instance + * @param {google.cloud.documentai.v1beta3.IListEvaluationsRequest} request ListEvaluationsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + return DocumentProcessorService; })(); @@ -74538,29 +75254,28 @@ return SetDefaultProcessorVersionMetadata; })(); - v1beta3.ReviewDocumentRequest = (function() { + v1beta3.TrainProcessorVersionRequest = (function() { /** - * Properties of a ReviewDocumentRequest. + * Properties of a TrainProcessorVersionRequest. * @memberof google.cloud.documentai.v1beta3 - * @interface IReviewDocumentRequest - * @property {google.cloud.documentai.v1beta3.IDocument|null} [inlineDocument] ReviewDocumentRequest inlineDocument - * @property {string|null} [humanReviewConfig] ReviewDocumentRequest humanReviewConfig - * @property {google.cloud.documentai.v1beta3.IDocument|null} [document] ReviewDocumentRequest document - * @property {boolean|null} [enableSchemaValidation] ReviewDocumentRequest enableSchemaValidation - * @property {google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority|null} [priority] ReviewDocumentRequest priority - * @property {google.cloud.documentai.v1beta3.IDocumentSchema|null} [documentSchema] ReviewDocumentRequest documentSchema + * @interface ITrainProcessorVersionRequest + * @property {string|null} [parent] TrainProcessorVersionRequest parent + * @property {google.cloud.documentai.v1beta3.IProcessorVersion|null} [processorVersion] TrainProcessorVersionRequest processorVersion + * @property {google.cloud.documentai.v1beta3.IDocumentSchema|null} [documentSchema] TrainProcessorVersionRequest documentSchema + * @property {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData|null} [inputData] TrainProcessorVersionRequest inputData + * @property {string|null} [baseProcessorVersion] TrainProcessorVersionRequest baseProcessorVersion */ /** - * Constructs a new ReviewDocumentRequest. + * Constructs a new TrainProcessorVersionRequest. * @memberof google.cloud.documentai.v1beta3 - * @classdesc Represents a ReviewDocumentRequest. - * @implements IReviewDocumentRequest + * @classdesc Represents a TrainProcessorVersionRequest. + * @implements ITrainProcessorVersionRequest * @constructor - * @param {google.cloud.documentai.v1beta3.IReviewDocumentRequest=} [properties] Properties to set + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest=} [properties] Properties to set */ - function ReviewDocumentRequest(properties) { + function TrainProcessorVersionRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -74568,159 +75283,131 @@ } /** - * ReviewDocumentRequest inlineDocument. - * @member {google.cloud.documentai.v1beta3.IDocument|null|undefined} inlineDocument - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest - * @instance - */ - ReviewDocumentRequest.prototype.inlineDocument = null; - - /** - * ReviewDocumentRequest humanReviewConfig. - * @member {string} humanReviewConfig - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest - * @instance - */ - ReviewDocumentRequest.prototype.humanReviewConfig = ""; - - /** - * ReviewDocumentRequest document. - * @member {google.cloud.documentai.v1beta3.IDocument|null|undefined} document - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * TrainProcessorVersionRequest parent. + * @member {string} parent + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @instance */ - ReviewDocumentRequest.prototype.document = null; + TrainProcessorVersionRequest.prototype.parent = ""; /** - * ReviewDocumentRequest enableSchemaValidation. - * @member {boolean} enableSchemaValidation - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * TrainProcessorVersionRequest processorVersion. + * @member {google.cloud.documentai.v1beta3.IProcessorVersion|null|undefined} processorVersion + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @instance */ - ReviewDocumentRequest.prototype.enableSchemaValidation = false; + TrainProcessorVersionRequest.prototype.processorVersion = null; /** - * ReviewDocumentRequest priority. - * @member {google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority} priority - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * TrainProcessorVersionRequest documentSchema. + * @member {google.cloud.documentai.v1beta3.IDocumentSchema|null|undefined} documentSchema + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @instance */ - ReviewDocumentRequest.prototype.priority = 0; + TrainProcessorVersionRequest.prototype.documentSchema = null; /** - * ReviewDocumentRequest documentSchema. - * @member {google.cloud.documentai.v1beta3.IDocumentSchema|null|undefined} documentSchema - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * TrainProcessorVersionRequest inputData. + * @member {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData|null|undefined} inputData + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @instance */ - ReviewDocumentRequest.prototype.documentSchema = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; + TrainProcessorVersionRequest.prototype.inputData = null; /** - * ReviewDocumentRequest source. - * @member {"inlineDocument"|undefined} source - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * TrainProcessorVersionRequest baseProcessorVersion. + * @member {string} baseProcessorVersion + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @instance */ - Object.defineProperty(ReviewDocumentRequest.prototype, "source", { - get: $util.oneOfGetter($oneOfFields = ["inlineDocument"]), - set: $util.oneOfSetter($oneOfFields) - }); + TrainProcessorVersionRequest.prototype.baseProcessorVersion = ""; /** - * Creates a new ReviewDocumentRequest instance using the specified properties. + * Creates a new TrainProcessorVersionRequest instance using the specified properties. * @function create - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @static - * @param {google.cloud.documentai.v1beta3.IReviewDocumentRequest=} [properties] Properties to set - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentRequest} ReviewDocumentRequest instance + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest} TrainProcessorVersionRequest instance */ - ReviewDocumentRequest.create = function create(properties) { - return new ReviewDocumentRequest(properties); + TrainProcessorVersionRequest.create = function create(properties) { + return new TrainProcessorVersionRequest(properties); }; /** - * Encodes the specified ReviewDocumentRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentRequest.verify|verify} messages. + * Encodes the specified TrainProcessorVersionRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.verify|verify} messages. * @function encode - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @static - * @param {google.cloud.documentai.v1beta3.IReviewDocumentRequest} message ReviewDocumentRequest message or plain object to encode + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest} message TrainProcessorVersionRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ReviewDocumentRequest.encode = function encode(message, writer) { + TrainProcessorVersionRequest.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.humanReviewConfig != null && Object.hasOwnProperty.call(message, "humanReviewConfig")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.humanReviewConfig); - if (message.document != null && Object.hasOwnProperty.call(message, "document")) - $root.google.cloud.documentai.v1beta3.Document.encode(message.document, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.enableSchemaValidation != null && Object.hasOwnProperty.call(message, "enableSchemaValidation")) - writer.uint32(/* id 3, wireType 0 =*/24).bool(message.enableSchemaValidation); - if (message.inlineDocument != null && Object.hasOwnProperty.call(message, "inlineDocument")) - $root.google.cloud.documentai.v1beta3.Document.encode(message.inlineDocument, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.priority != null && Object.hasOwnProperty.call(message, "priority")) - writer.uint32(/* id 5, wireType 0 =*/40).int32(message.priority); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.processorVersion != null && Object.hasOwnProperty.call(message, "processorVersion")) + $root.google.cloud.documentai.v1beta3.ProcessorVersion.encode(message.processorVersion, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.inputData != null && Object.hasOwnProperty.call(message, "inputData")) + $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.encode(message.inputData, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.baseProcessorVersion != null && Object.hasOwnProperty.call(message, "baseProcessorVersion")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.baseProcessorVersion); if (message.documentSchema != null && Object.hasOwnProperty.call(message, "documentSchema")) - $root.google.cloud.documentai.v1beta3.DocumentSchema.encode(message.documentSchema, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + $root.google.cloud.documentai.v1beta3.DocumentSchema.encode(message.documentSchema, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); return writer; }; /** - * Encodes the specified ReviewDocumentRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentRequest.verify|verify} messages. + * Encodes the specified TrainProcessorVersionRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.verify|verify} messages. * @function encodeDelimited - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @static - * @param {google.cloud.documentai.v1beta3.IReviewDocumentRequest} message ReviewDocumentRequest message or plain object to encode + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest} message TrainProcessorVersionRequest message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ReviewDocumentRequest.encodeDelimited = function encodeDelimited(message, writer) { + TrainProcessorVersionRequest.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a ReviewDocumentRequest message from the specified reader or buffer. + * Decodes a TrainProcessorVersionRequest message from the specified reader or buffer. * @function decode - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentRequest} ReviewDocumentRequest + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest} TrainProcessorVersionRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ReviewDocumentRequest.decode = function decode(reader, length) { + TrainProcessorVersionRequest.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentRequest(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 4: { - message.inlineDocument = $root.google.cloud.documentai.v1beta3.Document.decode(reader, reader.uint32()); - break; - } case 1: { - message.humanReviewConfig = reader.string(); + message.parent = reader.string(); break; } case 2: { - message.document = $root.google.cloud.documentai.v1beta3.Document.decode(reader, reader.uint32()); + message.processorVersion = $root.google.cloud.documentai.v1beta3.ProcessorVersion.decode(reader, reader.uint32()); break; } - case 3: { - message.enableSchemaValidation = reader.bool(); + case 10: { + message.documentSchema = $root.google.cloud.documentai.v1beta3.DocumentSchema.decode(reader, reader.uint32()); break; } - case 5: { - message.priority = reader.int32(); + case 4: { + message.inputData = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.decode(reader, reader.uint32()); break; } - case 6: { - message.documentSchema = $root.google.cloud.documentai.v1beta3.DocumentSchema.decode(reader, reader.uint32()); + case 8: { + message.baseProcessorVersion = reader.string(); break; } default: @@ -74732,219 +75419,407 @@ }; /** - * Decodes a ReviewDocumentRequest message from the specified reader or buffer, length delimited. + * Decodes a TrainProcessorVersionRequest message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentRequest} ReviewDocumentRequest + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest} TrainProcessorVersionRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ReviewDocumentRequest.decodeDelimited = function decodeDelimited(reader) { + TrainProcessorVersionRequest.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a ReviewDocumentRequest message. + * Verifies a TrainProcessorVersionRequest message. * @function verify - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - ReviewDocumentRequest.verify = function verify(message) { + TrainProcessorVersionRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - var properties = {}; - if (message.inlineDocument != null && message.hasOwnProperty("inlineDocument")) { - properties.source = 1; - { - var error = $root.google.cloud.documentai.v1beta3.Document.verify(message.inlineDocument); - if (error) - return "inlineDocument." + error; - } - } - if (message.humanReviewConfig != null && message.hasOwnProperty("humanReviewConfig")) - if (!$util.isString(message.humanReviewConfig)) - return "humanReviewConfig: string expected"; - if (message.document != null && message.hasOwnProperty("document")) { - var error = $root.google.cloud.documentai.v1beta3.Document.verify(message.document); + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.processorVersion != null && message.hasOwnProperty("processorVersion")) { + var error = $root.google.cloud.documentai.v1beta3.ProcessorVersion.verify(message.processorVersion); if (error) - return "document." + error; + return "processorVersion." + error; } - if (message.enableSchemaValidation != null && message.hasOwnProperty("enableSchemaValidation")) - if (typeof message.enableSchemaValidation !== "boolean") - return "enableSchemaValidation: boolean expected"; - if (message.priority != null && message.hasOwnProperty("priority")) - switch (message.priority) { - default: - return "priority: enum value expected"; - case 0: - case 1: - break; - } if (message.documentSchema != null && message.hasOwnProperty("documentSchema")) { var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.verify(message.documentSchema); if (error) return "documentSchema." + error; } + if (message.inputData != null && message.hasOwnProperty("inputData")) { + var error = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.verify(message.inputData); + if (error) + return "inputData." + error; + } + if (message.baseProcessorVersion != null && message.hasOwnProperty("baseProcessorVersion")) + if (!$util.isString(message.baseProcessorVersion)) + return "baseProcessorVersion: string expected"; return null; }; /** - * Creates a ReviewDocumentRequest message from a plain object. Also converts values to their respective internal types. + * Creates a TrainProcessorVersionRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @static * @param {Object.} object Plain object - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentRequest} ReviewDocumentRequest + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest} TrainProcessorVersionRequest */ - ReviewDocumentRequest.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.documentai.v1beta3.ReviewDocumentRequest) + TrainProcessorVersionRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest) return object; - var message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentRequest(); - if (object.inlineDocument != null) { - if (typeof object.inlineDocument !== "object") - throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentRequest.inlineDocument: object expected"); - message.inlineDocument = $root.google.cloud.documentai.v1beta3.Document.fromObject(object.inlineDocument); - } - if (object.humanReviewConfig != null) - message.humanReviewConfig = String(object.humanReviewConfig); - if (object.document != null) { - if (typeof object.document !== "object") - throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentRequest.document: object expected"); - message.document = $root.google.cloud.documentai.v1beta3.Document.fromObject(object.document); - } - if (object.enableSchemaValidation != null) - message.enableSchemaValidation = Boolean(object.enableSchemaValidation); - switch (object.priority) { - default: - if (typeof object.priority === "number") { - message.priority = object.priority; - break; - } - break; - case "DEFAULT": - case 0: - message.priority = 0; - break; - case "URGENT": - case 1: - message.priority = 1; - break; + var message = new $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.processorVersion != null) { + if (typeof object.processorVersion !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.processorVersion: object expected"); + message.processorVersion = $root.google.cloud.documentai.v1beta3.ProcessorVersion.fromObject(object.processorVersion); } if (object.documentSchema != null) { if (typeof object.documentSchema !== "object") - throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentRequest.documentSchema: object expected"); + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.documentSchema: object expected"); message.documentSchema = $root.google.cloud.documentai.v1beta3.DocumentSchema.fromObject(object.documentSchema); } + if (object.inputData != null) { + if (typeof object.inputData !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.inputData: object expected"); + message.inputData = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.fromObject(object.inputData); + } + if (object.baseProcessorVersion != null) + message.baseProcessorVersion = String(object.baseProcessorVersion); return message; }; /** - * Creates a plain object from a ReviewDocumentRequest message. Also converts values to other types if specified. + * Creates a plain object from a TrainProcessorVersionRequest message. Also converts values to other types if specified. * @function toObject - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @static - * @param {google.cloud.documentai.v1beta3.ReviewDocumentRequest} message ReviewDocumentRequest + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest} message TrainProcessorVersionRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ReviewDocumentRequest.toObject = function toObject(message, options) { + TrainProcessorVersionRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.humanReviewConfig = ""; - object.document = null; - object.enableSchemaValidation = false; - object.priority = options.enums === String ? "DEFAULT" : 0; + object.parent = ""; + object.processorVersion = null; + object.inputData = null; + object.baseProcessorVersion = ""; object.documentSchema = null; } - if (message.humanReviewConfig != null && message.hasOwnProperty("humanReviewConfig")) - object.humanReviewConfig = message.humanReviewConfig; - if (message.document != null && message.hasOwnProperty("document")) - object.document = $root.google.cloud.documentai.v1beta3.Document.toObject(message.document, options); - if (message.enableSchemaValidation != null && message.hasOwnProperty("enableSchemaValidation")) - object.enableSchemaValidation = message.enableSchemaValidation; - if (message.inlineDocument != null && message.hasOwnProperty("inlineDocument")) { - object.inlineDocument = $root.google.cloud.documentai.v1beta3.Document.toObject(message.inlineDocument, options); - if (options.oneofs) - object.source = "inlineDocument"; - } - if (message.priority != null && message.hasOwnProperty("priority")) - object.priority = options.enums === String ? $root.google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority[message.priority] === undefined ? message.priority : $root.google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority[message.priority] : message.priority; + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.processorVersion != null && message.hasOwnProperty("processorVersion")) + object.processorVersion = $root.google.cloud.documentai.v1beta3.ProcessorVersion.toObject(message.processorVersion, options); + if (message.inputData != null && message.hasOwnProperty("inputData")) + object.inputData = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.toObject(message.inputData, options); + if (message.baseProcessorVersion != null && message.hasOwnProperty("baseProcessorVersion")) + object.baseProcessorVersion = message.baseProcessorVersion; if (message.documentSchema != null && message.hasOwnProperty("documentSchema")) object.documentSchema = $root.google.cloud.documentai.v1beta3.DocumentSchema.toObject(message.documentSchema, options); return object; }; /** - * Converts this ReviewDocumentRequest to JSON. + * Converts this TrainProcessorVersionRequest to JSON. * @function toJSON - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @instance * @returns {Object.} JSON object */ - ReviewDocumentRequest.prototype.toJSON = function toJSON() { + TrainProcessorVersionRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for ReviewDocumentRequest + * Gets the default type url for TrainProcessorVersionRequest * @function getTypeUrl - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ReviewDocumentRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + TrainProcessorVersionRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ReviewDocumentRequest"; + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.TrainProcessorVersionRequest"; }; - /** - * Priority enum. - * @name google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority - * @enum {number} - * @property {number} DEFAULT=0 DEFAULT value - * @property {number} URGENT=1 URGENT value - */ - ReviewDocumentRequest.Priority = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "DEFAULT"] = 0; - values[valuesById[1] = "URGENT"] = 1; - return values; + TrainProcessorVersionRequest.InputData = (function() { + + /** + * Properties of an InputData. + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest + * @interface IInputData + * @property {google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null} [trainingDocuments] InputData trainingDocuments + * @property {google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null} [testDocuments] InputData testDocuments + */ + + /** + * Constructs a new InputData. + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest + * @classdesc Represents an InputData. + * @implements IInputData + * @constructor + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData=} [properties] Properties to set + */ + function InputData(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * InputData trainingDocuments. + * @member {google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null|undefined} trainingDocuments + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @instance + */ + InputData.prototype.trainingDocuments = null; + + /** + * InputData testDocuments. + * @member {google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null|undefined} testDocuments + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @instance + */ + InputData.prototype.testDocuments = null; + + /** + * Creates a new InputData instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @static + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData} InputData instance + */ + InputData.create = function create(properties) { + return new InputData(properties); + }; + + /** + * Encodes the specified InputData message. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @static + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData} message InputData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InputData.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.trainingDocuments != null && Object.hasOwnProperty.call(message, "trainingDocuments")) + $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.encode(message.trainingDocuments, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.testDocuments != null && Object.hasOwnProperty.call(message, "testDocuments")) + $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.encode(message.testDocuments, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified InputData message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @static + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.IInputData} message InputData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InputData.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an InputData message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData} InputData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InputData.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.trainingDocuments = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.decode(reader, reader.uint32()); + break; + } + case 4: { + message.testDocuments = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an InputData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData} InputData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InputData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an InputData message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + InputData.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.trainingDocuments != null && message.hasOwnProperty("trainingDocuments")) { + var error = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.verify(message.trainingDocuments); + if (error) + return "trainingDocuments." + error; + } + if (message.testDocuments != null && message.hasOwnProperty("testDocuments")) { + var error = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.verify(message.testDocuments); + if (error) + return "testDocuments." + error; + } + return null; + }; + + /** + * Creates an InputData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData} InputData + */ + InputData.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData) + return object; + var message = new $root.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData(); + if (object.trainingDocuments != null) { + if (typeof object.trainingDocuments !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.trainingDocuments: object expected"); + message.trainingDocuments = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.fromObject(object.trainingDocuments); + } + if (object.testDocuments != null) { + if (typeof object.testDocuments !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData.testDocuments: object expected"); + message.testDocuments = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.fromObject(object.testDocuments); + } + return message; + }; + + /** + * Creates a plain object from an InputData message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @static + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData} message InputData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + InputData.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.trainingDocuments = null; + object.testDocuments = null; + } + if (message.trainingDocuments != null && message.hasOwnProperty("trainingDocuments")) + object.trainingDocuments = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.toObject(message.trainingDocuments, options); + if (message.testDocuments != null && message.hasOwnProperty("testDocuments")) + object.testDocuments = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.toObject(message.testDocuments, options); + return object; + }; + + /** + * Converts this InputData to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @instance + * @returns {Object.} JSON object + */ + InputData.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for InputData + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + InputData.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData"; + }; + + return InputData; })(); - return ReviewDocumentRequest; + return TrainProcessorVersionRequest; })(); - v1beta3.ReviewDocumentResponse = (function() { + v1beta3.TrainProcessorVersionResponse = (function() { /** - * Properties of a ReviewDocumentResponse. + * Properties of a TrainProcessorVersionResponse. * @memberof google.cloud.documentai.v1beta3 - * @interface IReviewDocumentResponse - * @property {string|null} [gcsDestination] ReviewDocumentResponse gcsDestination - * @property {google.cloud.documentai.v1beta3.ReviewDocumentResponse.State|null} [state] ReviewDocumentResponse state - * @property {string|null} [rejectionReason] ReviewDocumentResponse rejectionReason + * @interface ITrainProcessorVersionResponse + * @property {string|null} [processorVersion] TrainProcessorVersionResponse processorVersion */ /** - * Constructs a new ReviewDocumentResponse. + * Constructs a new TrainProcessorVersionResponse. * @memberof google.cloud.documentai.v1beta3 - * @classdesc Represents a ReviewDocumentResponse. - * @implements IReviewDocumentResponse + * @classdesc Represents a TrainProcessorVersionResponse. + * @implements ITrainProcessorVersionResponse * @constructor - * @param {google.cloud.documentai.v1beta3.IReviewDocumentResponse=} [properties] Properties to set + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse=} [properties] Properties to set */ - function ReviewDocumentResponse(properties) { + function TrainProcessorVersionResponse(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -74952,103 +75827,75 @@ } /** - * ReviewDocumentResponse gcsDestination. - * @member {string} gcsDestination - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse - * @instance - */ - ReviewDocumentResponse.prototype.gcsDestination = ""; - - /** - * ReviewDocumentResponse state. - * @member {google.cloud.documentai.v1beta3.ReviewDocumentResponse.State} state - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse - * @instance - */ - ReviewDocumentResponse.prototype.state = 0; - - /** - * ReviewDocumentResponse rejectionReason. - * @member {string} rejectionReason - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * TrainProcessorVersionResponse processorVersion. + * @member {string} processorVersion + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @instance */ - ReviewDocumentResponse.prototype.rejectionReason = ""; + TrainProcessorVersionResponse.prototype.processorVersion = ""; /** - * Creates a new ReviewDocumentResponse instance using the specified properties. + * Creates a new TrainProcessorVersionResponse instance using the specified properties. * @function create - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @static - * @param {google.cloud.documentai.v1beta3.IReviewDocumentResponse=} [properties] Properties to set - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentResponse} ReviewDocumentResponse instance + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionResponse} TrainProcessorVersionResponse instance */ - ReviewDocumentResponse.create = function create(properties) { - return new ReviewDocumentResponse(properties); + TrainProcessorVersionResponse.create = function create(properties) { + return new TrainProcessorVersionResponse(properties); }; /** - * Encodes the specified ReviewDocumentResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentResponse.verify|verify} messages. + * Encodes the specified TrainProcessorVersionResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionResponse.verify|verify} messages. * @function encode - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @static - * @param {google.cloud.documentai.v1beta3.IReviewDocumentResponse} message ReviewDocumentResponse message or plain object to encode + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse} message TrainProcessorVersionResponse message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ReviewDocumentResponse.encode = function encode(message, writer) { + TrainProcessorVersionResponse.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.gcsDestination != null && Object.hasOwnProperty.call(message, "gcsDestination")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.gcsDestination); - if (message.state != null && Object.hasOwnProperty.call(message, "state")) - writer.uint32(/* id 2, wireType 0 =*/16).int32(message.state); - if (message.rejectionReason != null && Object.hasOwnProperty.call(message, "rejectionReason")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.rejectionReason); + if (message.processorVersion != null && Object.hasOwnProperty.call(message, "processorVersion")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.processorVersion); return writer; }; /** - * Encodes the specified ReviewDocumentResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentResponse.verify|verify} messages. + * Encodes the specified TrainProcessorVersionResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionResponse.verify|verify} messages. * @function encodeDelimited - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @static - * @param {google.cloud.documentai.v1beta3.IReviewDocumentResponse} message ReviewDocumentResponse message or plain object to encode + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse} message TrainProcessorVersionResponse message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ReviewDocumentResponse.encodeDelimited = function encodeDelimited(message, writer) { + TrainProcessorVersionResponse.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a ReviewDocumentResponse message from the specified reader or buffer. + * Decodes a TrainProcessorVersionResponse message from the specified reader or buffer. * @function decode - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentResponse} ReviewDocumentResponse + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionResponse} TrainProcessorVersionResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ReviewDocumentResponse.decode = function decode(reader, length) { + TrainProcessorVersionResponse.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentResponse(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.TrainProcessorVersionResponse(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.gcsDestination = reader.string(); - break; - } - case 2: { - message.state = reader.int32(); - break; - } - case 3: { - message.rejectionReason = reader.string(); + message.processorVersion = reader.string(); break; } default: @@ -75060,184 +75907,124 @@ }; /** - * Decodes a ReviewDocumentResponse message from the specified reader or buffer, length delimited. + * Decodes a TrainProcessorVersionResponse message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentResponse} ReviewDocumentResponse + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionResponse} TrainProcessorVersionResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ReviewDocumentResponse.decodeDelimited = function decodeDelimited(reader) { + TrainProcessorVersionResponse.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a ReviewDocumentResponse message. + * Verifies a TrainProcessorVersionResponse message. * @function verify - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - ReviewDocumentResponse.verify = function verify(message) { + TrainProcessorVersionResponse.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.gcsDestination != null && message.hasOwnProperty("gcsDestination")) - if (!$util.isString(message.gcsDestination)) - return "gcsDestination: string expected"; - if (message.state != null && message.hasOwnProperty("state")) - switch (message.state) { - default: - return "state: enum value expected"; - case 0: - case 1: - case 2: - break; - } - if (message.rejectionReason != null && message.hasOwnProperty("rejectionReason")) - if (!$util.isString(message.rejectionReason)) - return "rejectionReason: string expected"; + if (message.processorVersion != null && message.hasOwnProperty("processorVersion")) + if (!$util.isString(message.processorVersion)) + return "processorVersion: string expected"; return null; }; /** - * Creates a ReviewDocumentResponse message from a plain object. Also converts values to their respective internal types. + * Creates a TrainProcessorVersionResponse message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @static * @param {Object.} object Plain object - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentResponse} ReviewDocumentResponse + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionResponse} TrainProcessorVersionResponse */ - ReviewDocumentResponse.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.documentai.v1beta3.ReviewDocumentResponse) + TrainProcessorVersionResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.TrainProcessorVersionResponse) return object; - var message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentResponse(); - if (object.gcsDestination != null) - message.gcsDestination = String(object.gcsDestination); - switch (object.state) { - default: - if (typeof object.state === "number") { - message.state = object.state; - break; - } - break; - case "STATE_UNSPECIFIED": - case 0: - message.state = 0; - break; - case "REJECTED": - case 1: - message.state = 1; - break; - case "SUCCEEDED": - case 2: - message.state = 2; - break; - } - if (object.rejectionReason != null) - message.rejectionReason = String(object.rejectionReason); + var message = new $root.google.cloud.documentai.v1beta3.TrainProcessorVersionResponse(); + if (object.processorVersion != null) + message.processorVersion = String(object.processorVersion); return message; }; /** - * Creates a plain object from a ReviewDocumentResponse message. Also converts values to other types if specified. + * Creates a plain object from a TrainProcessorVersionResponse message. Also converts values to other types if specified. * @function toObject - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @static - * @param {google.cloud.documentai.v1beta3.ReviewDocumentResponse} message ReviewDocumentResponse + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionResponse} message TrainProcessorVersionResponse * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ReviewDocumentResponse.toObject = function toObject(message, options) { + TrainProcessorVersionResponse.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.defaults) { - object.gcsDestination = ""; - object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; - object.rejectionReason = ""; - } - if (message.gcsDestination != null && message.hasOwnProperty("gcsDestination")) - object.gcsDestination = message.gcsDestination; - if (message.state != null && message.hasOwnProperty("state")) - object.state = options.enums === String ? $root.google.cloud.documentai.v1beta3.ReviewDocumentResponse.State[message.state] === undefined ? message.state : $root.google.cloud.documentai.v1beta3.ReviewDocumentResponse.State[message.state] : message.state; - if (message.rejectionReason != null && message.hasOwnProperty("rejectionReason")) - object.rejectionReason = message.rejectionReason; + if (options.defaults) + object.processorVersion = ""; + if (message.processorVersion != null && message.hasOwnProperty("processorVersion")) + object.processorVersion = message.processorVersion; return object; }; /** - * Converts this ReviewDocumentResponse to JSON. + * Converts this TrainProcessorVersionResponse to JSON. * @function toJSON - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @instance * @returns {Object.} JSON object */ - ReviewDocumentResponse.prototype.toJSON = function toJSON() { + TrainProcessorVersionResponse.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for ReviewDocumentResponse + * Gets the default type url for TrainProcessorVersionResponse * @function getTypeUrl - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionResponse * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ReviewDocumentResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + TrainProcessorVersionResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ReviewDocumentResponse"; + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.TrainProcessorVersionResponse"; }; - /** - * State enum. - * @name google.cloud.documentai.v1beta3.ReviewDocumentResponse.State - * @enum {number} - * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value - * @property {number} REJECTED=1 REJECTED value - * @property {number} SUCCEEDED=2 SUCCEEDED value - */ - ReviewDocumentResponse.State = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; - values[valuesById[1] = "REJECTED"] = 1; - values[valuesById[2] = "SUCCEEDED"] = 2; - return values; - })(); - - return ReviewDocumentResponse; + return TrainProcessorVersionResponse; })(); - v1beta3.ReviewDocumentOperationMetadata = (function() { + v1beta3.TrainProcessorVersionMetadata = (function() { /** - * Properties of a ReviewDocumentOperationMetadata. + * Properties of a TrainProcessorVersionMetadata. * @memberof google.cloud.documentai.v1beta3 - * @interface IReviewDocumentOperationMetadata - * @property {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State|null} [state] ReviewDocumentOperationMetadata state - * @property {string|null} [stateMessage] ReviewDocumentOperationMetadata stateMessage - * @property {google.protobuf.ITimestamp|null} [createTime] ReviewDocumentOperationMetadata createTime - * @property {google.protobuf.ITimestamp|null} [updateTime] ReviewDocumentOperationMetadata updateTime - * @property {google.cloud.documentai.v1beta3.ICommonOperationMetadata|null} [commonMetadata] ReviewDocumentOperationMetadata commonMetadata - * @property {string|null} [questionId] ReviewDocumentOperationMetadata questionId + * @interface ITrainProcessorVersionMetadata + * @property {google.cloud.documentai.v1beta3.ICommonOperationMetadata|null} [commonMetadata] TrainProcessorVersionMetadata commonMetadata + * @property {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation|null} [trainingDatasetValidation] TrainProcessorVersionMetadata trainingDatasetValidation + * @property {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation|null} [testDatasetValidation] TrainProcessorVersionMetadata testDatasetValidation */ /** - * Constructs a new ReviewDocumentOperationMetadata. + * Constructs a new TrainProcessorVersionMetadata. * @memberof google.cloud.documentai.v1beta3 - * @classdesc Represents a ReviewDocumentOperationMetadata. - * @implements IReviewDocumentOperationMetadata + * @classdesc Represents a TrainProcessorVersionMetadata. + * @implements ITrainProcessorVersionMetadata * @constructor - * @param {google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata=} [properties] Properties to set + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata=} [properties] Properties to set */ - function ReviewDocumentOperationMetadata(properties) { + function TrainProcessorVersionMetadata(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -75245,145 +76032,103 @@ } /** - * ReviewDocumentOperationMetadata state. - * @member {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State} state - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata - * @instance - */ - ReviewDocumentOperationMetadata.prototype.state = 0; - - /** - * ReviewDocumentOperationMetadata stateMessage. - * @member {string} stateMessage - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata - * @instance - */ - ReviewDocumentOperationMetadata.prototype.stateMessage = ""; - - /** - * ReviewDocumentOperationMetadata createTime. - * @member {google.protobuf.ITimestamp|null|undefined} createTime - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata - * @instance - */ - ReviewDocumentOperationMetadata.prototype.createTime = null; - - /** - * ReviewDocumentOperationMetadata updateTime. - * @member {google.protobuf.ITimestamp|null|undefined} updateTime - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * TrainProcessorVersionMetadata commonMetadata. + * @member {google.cloud.documentai.v1beta3.ICommonOperationMetadata|null|undefined} commonMetadata + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @instance */ - ReviewDocumentOperationMetadata.prototype.updateTime = null; + TrainProcessorVersionMetadata.prototype.commonMetadata = null; /** - * ReviewDocumentOperationMetadata commonMetadata. - * @member {google.cloud.documentai.v1beta3.ICommonOperationMetadata|null|undefined} commonMetadata - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * TrainProcessorVersionMetadata trainingDatasetValidation. + * @member {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation|null|undefined} trainingDatasetValidation + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @instance */ - ReviewDocumentOperationMetadata.prototype.commonMetadata = null; + TrainProcessorVersionMetadata.prototype.trainingDatasetValidation = null; /** - * ReviewDocumentOperationMetadata questionId. - * @member {string} questionId - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * TrainProcessorVersionMetadata testDatasetValidation. + * @member {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation|null|undefined} testDatasetValidation + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @instance */ - ReviewDocumentOperationMetadata.prototype.questionId = ""; + TrainProcessorVersionMetadata.prototype.testDatasetValidation = null; /** - * Creates a new ReviewDocumentOperationMetadata instance using the specified properties. + * Creates a new TrainProcessorVersionMetadata instance using the specified properties. * @function create - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @static - * @param {google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata=} [properties] Properties to set - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata} ReviewDocumentOperationMetadata instance + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata} TrainProcessorVersionMetadata instance */ - ReviewDocumentOperationMetadata.create = function create(properties) { - return new ReviewDocumentOperationMetadata(properties); + TrainProcessorVersionMetadata.create = function create(properties) { + return new TrainProcessorVersionMetadata(properties); }; /** - * Encodes the specified ReviewDocumentOperationMetadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.verify|verify} messages. + * Encodes the specified TrainProcessorVersionMetadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.verify|verify} messages. * @function encode - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @static - * @param {google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata} message ReviewDocumentOperationMetadata message or plain object to encode + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata} message TrainProcessorVersionMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ReviewDocumentOperationMetadata.encode = function encode(message, writer) { + TrainProcessorVersionMetadata.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.state != null && Object.hasOwnProperty.call(message, "state")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.state); - if (message.stateMessage != null && Object.hasOwnProperty.call(message, "stateMessage")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.stateMessage); - if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) - $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) - $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.commonMetadata != null && Object.hasOwnProperty.call(message, "commonMetadata")) - $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.encode(message.commonMetadata, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - if (message.questionId != null && Object.hasOwnProperty.call(message, "questionId")) - writer.uint32(/* id 6, wireType 2 =*/50).string(message.questionId); + $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.encode(message.commonMetadata, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.trainingDatasetValidation != null && Object.hasOwnProperty.call(message, "trainingDatasetValidation")) + $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.encode(message.trainingDatasetValidation, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.testDatasetValidation != null && Object.hasOwnProperty.call(message, "testDatasetValidation")) + $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.encode(message.testDatasetValidation, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; /** - * Encodes the specified ReviewDocumentOperationMetadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.verify|verify} messages. + * Encodes the specified TrainProcessorVersionMetadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.verify|verify} messages. * @function encodeDelimited - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @static - * @param {google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata} message ReviewDocumentOperationMetadata message or plain object to encode + * @param {google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata} message TrainProcessorVersionMetadata message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ReviewDocumentOperationMetadata.encodeDelimited = function encodeDelimited(message, writer) { + TrainProcessorVersionMetadata.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a ReviewDocumentOperationMetadata message from the specified reader or buffer. + * Decodes a TrainProcessorVersionMetadata message from the specified reader or buffer. * @function decode - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata} ReviewDocumentOperationMetadata + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata} TrainProcessorVersionMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ReviewDocumentOperationMetadata.decode = function decode(reader, length) { + TrainProcessorVersionMetadata.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.state = reader.int32(); + message.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.decode(reader, reader.uint32()); break; } case 2: { - message.stateMessage = reader.string(); + message.trainingDatasetValidation = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.decode(reader, reader.uint32()); break; } case 3: { - message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); - break; - } - case 4: { - message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); - break; - } - case 5: { - message.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.decode(reader, reader.uint32()); - break; - } - case 6: { - message.questionId = reader.string(); + message.testDatasetValidation = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.decode(reader, reader.uint32()); break; } default: @@ -75395,243 +76140,4350 @@ }; /** - * Decodes a ReviewDocumentOperationMetadata message from the specified reader or buffer, length delimited. + * Decodes a TrainProcessorVersionMetadata message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata} ReviewDocumentOperationMetadata + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata} TrainProcessorVersionMetadata * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ReviewDocumentOperationMetadata.decodeDelimited = function decodeDelimited(reader) { + TrainProcessorVersionMetadata.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a ReviewDocumentOperationMetadata message. + * Verifies a TrainProcessorVersionMetadata message. * @function verify - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - ReviewDocumentOperationMetadata.verify = function verify(message) { + TrainProcessorVersionMetadata.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.state != null && message.hasOwnProperty("state")) - switch (message.state) { - default: - return "state: enum value expected"; - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - break; - } - if (message.stateMessage != null && message.hasOwnProperty("stateMessage")) - if (!$util.isString(message.stateMessage)) - return "stateMessage: string expected"; - if (message.createTime != null && message.hasOwnProperty("createTime")) { - var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (message.commonMetadata != null && message.hasOwnProperty("commonMetadata")) { + var error = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.verify(message.commonMetadata); if (error) - return "createTime." + error; + return "commonMetadata." + error; } - if (message.updateTime != null && message.hasOwnProperty("updateTime")) { - var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (message.trainingDatasetValidation != null && message.hasOwnProperty("trainingDatasetValidation")) { + var error = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.verify(message.trainingDatasetValidation); if (error) - return "updateTime." + error; + return "trainingDatasetValidation." + error; } - if (message.commonMetadata != null && message.hasOwnProperty("commonMetadata")) { - var error = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.verify(message.commonMetadata); + if (message.testDatasetValidation != null && message.hasOwnProperty("testDatasetValidation")) { + var error = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.verify(message.testDatasetValidation); if (error) - return "commonMetadata." + error; + return "testDatasetValidation." + error; } - if (message.questionId != null && message.hasOwnProperty("questionId")) - if (!$util.isString(message.questionId)) - return "questionId: string expected"; return null; }; /** - * Creates a ReviewDocumentOperationMetadata message from a plain object. Also converts values to their respective internal types. + * Creates a TrainProcessorVersionMetadata message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @static * @param {Object.} object Plain object - * @returns {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata} ReviewDocumentOperationMetadata + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata} TrainProcessorVersionMetadata */ - ReviewDocumentOperationMetadata.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata) + TrainProcessorVersionMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata) return object; - var message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata(); - switch (object.state) { - default: - if (typeof object.state === "number") { - message.state = object.state; - break; - } - break; - case "STATE_UNSPECIFIED": - case 0: - message.state = 0; - break; - case "RUNNING": - case 1: - message.state = 1; - break; - case "CANCELLING": - case 2: - message.state = 2; - break; - case "SUCCEEDED": - case 3: - message.state = 3; - break; - case "FAILED": - case 4: - message.state = 4; - break; - case "CANCELLED": - case 5: - message.state = 5; - break; - } - if (object.stateMessage != null) - message.stateMessage = String(object.stateMessage); - if (object.createTime != null) { - if (typeof object.createTime !== "object") - throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.createTime: object expected"); - message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); - } - if (object.updateTime != null) { - if (typeof object.updateTime !== "object") - throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.updateTime: object expected"); - message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); - } + var message = new $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata(); if (object.commonMetadata != null) { if (typeof object.commonMetadata !== "object") - throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.commonMetadata: object expected"); + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.commonMetadata: object expected"); message.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.fromObject(object.commonMetadata); } - if (object.questionId != null) - message.questionId = String(object.questionId); + if (object.trainingDatasetValidation != null) { + if (typeof object.trainingDatasetValidation !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.trainingDatasetValidation: object expected"); + message.trainingDatasetValidation = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.fromObject(object.trainingDatasetValidation); + } + if (object.testDatasetValidation != null) { + if (typeof object.testDatasetValidation !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.testDatasetValidation: object expected"); + message.testDatasetValidation = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.fromObject(object.testDatasetValidation); + } return message; }; /** - * Creates a plain object from a ReviewDocumentOperationMetadata message. Also converts values to other types if specified. + * Creates a plain object from a TrainProcessorVersionMetadata message. Also converts values to other types if specified. * @function toObject - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata * @static - * @param {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata} message ReviewDocumentOperationMetadata + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata} message TrainProcessorVersionMetadata * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ReviewDocumentOperationMetadata.toObject = function toObject(message, options) { + TrainProcessorVersionMetadata.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; - object.stateMessage = ""; - object.createTime = null; - object.updateTime = null; object.commonMetadata = null; - object.questionId = ""; + object.trainingDatasetValidation = null; + object.testDatasetValidation = null; } - if (message.state != null && message.hasOwnProperty("state")) - object.state = options.enums === String ? $root.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State[message.state] === undefined ? message.state : $root.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State[message.state] : message.state; - if (message.stateMessage != null && message.hasOwnProperty("stateMessage")) - object.stateMessage = message.stateMessage; - if (message.createTime != null && message.hasOwnProperty("createTime")) - object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); - if (message.updateTime != null && message.hasOwnProperty("updateTime")) - object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); if (message.commonMetadata != null && message.hasOwnProperty("commonMetadata")) object.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.toObject(message.commonMetadata, options); - if (message.questionId != null && message.hasOwnProperty("questionId")) - object.questionId = message.questionId; + if (message.trainingDatasetValidation != null && message.hasOwnProperty("trainingDatasetValidation")) + object.trainingDatasetValidation = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.toObject(message.trainingDatasetValidation, options); + if (message.testDatasetValidation != null && message.hasOwnProperty("testDatasetValidation")) + object.testDatasetValidation = $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.toObject(message.testDatasetValidation, options); return object; }; - /** - * Converts this ReviewDocumentOperationMetadata to JSON. - * @function toJSON - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata - * @instance - * @returns {Object.} JSON object - */ - ReviewDocumentOperationMetadata.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + /** + * Converts this TrainProcessorVersionMetadata to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata + * @instance + * @returns {Object.} JSON object + */ + TrainProcessorVersionMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TrainProcessorVersionMetadata + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TrainProcessorVersionMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata"; + }; + + TrainProcessorVersionMetadata.DatasetValidation = (function() { + + /** + * Properties of a DatasetValidation. + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata + * @interface IDatasetValidation + * @property {number|null} [documentErrorCount] DatasetValidation documentErrorCount + * @property {number|null} [datasetErrorCount] DatasetValidation datasetErrorCount + * @property {Array.|null} [documentErrors] DatasetValidation documentErrors + * @property {Array.|null} [datasetErrors] DatasetValidation datasetErrors + */ + + /** + * Constructs a new DatasetValidation. + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata + * @classdesc Represents a DatasetValidation. + * @implements IDatasetValidation + * @constructor + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation=} [properties] Properties to set + */ + function DatasetValidation(properties) { + this.documentErrors = []; + this.datasetErrors = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DatasetValidation documentErrorCount. + * @member {number} documentErrorCount + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @instance + */ + DatasetValidation.prototype.documentErrorCount = 0; + + /** + * DatasetValidation datasetErrorCount. + * @member {number} datasetErrorCount + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @instance + */ + DatasetValidation.prototype.datasetErrorCount = 0; + + /** + * DatasetValidation documentErrors. + * @member {Array.} documentErrors + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @instance + */ + DatasetValidation.prototype.documentErrors = $util.emptyArray; + + /** + * DatasetValidation datasetErrors. + * @member {Array.} datasetErrors + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @instance + */ + DatasetValidation.prototype.datasetErrors = $util.emptyArray; + + /** + * Creates a new DatasetValidation instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @static + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation} DatasetValidation instance + */ + DatasetValidation.create = function create(properties) { + return new DatasetValidation(properties); + }; + + /** + * Encodes the specified DatasetValidation message. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @static + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation} message DatasetValidation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DatasetValidation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.documentErrors != null && message.documentErrors.length) + for (var i = 0; i < message.documentErrors.length; ++i) + $root.google.rpc.Status.encode(message.documentErrors[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.datasetErrors != null && message.datasetErrors.length) + for (var i = 0; i < message.datasetErrors.length; ++i) + $root.google.rpc.Status.encode(message.datasetErrors[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.documentErrorCount != null && Object.hasOwnProperty.call(message, "documentErrorCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.documentErrorCount); + if (message.datasetErrorCount != null && Object.hasOwnProperty.call(message, "datasetErrorCount")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.datasetErrorCount); + return writer; + }; + + /** + * Encodes the specified DatasetValidation message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @static + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.IDatasetValidation} message DatasetValidation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DatasetValidation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DatasetValidation message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation} DatasetValidation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DatasetValidation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.documentErrorCount = reader.int32(); + break; + } + case 4: { + message.datasetErrorCount = reader.int32(); + break; + } + case 1: { + if (!(message.documentErrors && message.documentErrors.length)) + message.documentErrors = []; + message.documentErrors.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + case 2: { + if (!(message.datasetErrors && message.datasetErrors.length)) + message.datasetErrors = []; + message.datasetErrors.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DatasetValidation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation} DatasetValidation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DatasetValidation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DatasetValidation message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DatasetValidation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.documentErrorCount != null && message.hasOwnProperty("documentErrorCount")) + if (!$util.isInteger(message.documentErrorCount)) + return "documentErrorCount: integer expected"; + if (message.datasetErrorCount != null && message.hasOwnProperty("datasetErrorCount")) + if (!$util.isInteger(message.datasetErrorCount)) + return "datasetErrorCount: integer expected"; + if (message.documentErrors != null && message.hasOwnProperty("documentErrors")) { + if (!Array.isArray(message.documentErrors)) + return "documentErrors: array expected"; + for (var i = 0; i < message.documentErrors.length; ++i) { + var error = $root.google.rpc.Status.verify(message.documentErrors[i]); + if (error) + return "documentErrors." + error; + } + } + if (message.datasetErrors != null && message.hasOwnProperty("datasetErrors")) { + if (!Array.isArray(message.datasetErrors)) + return "datasetErrors: array expected"; + for (var i = 0; i < message.datasetErrors.length; ++i) { + var error = $root.google.rpc.Status.verify(message.datasetErrors[i]); + if (error) + return "datasetErrors." + error; + } + } + return null; + }; + + /** + * Creates a DatasetValidation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation} DatasetValidation + */ + DatasetValidation.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation) + return object; + var message = new $root.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation(); + if (object.documentErrorCount != null) + message.documentErrorCount = object.documentErrorCount | 0; + if (object.datasetErrorCount != null) + message.datasetErrorCount = object.datasetErrorCount | 0; + if (object.documentErrors) { + if (!Array.isArray(object.documentErrors)) + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.documentErrors: array expected"); + message.documentErrors = []; + for (var i = 0; i < object.documentErrors.length; ++i) { + if (typeof object.documentErrors[i] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.documentErrors: object expected"); + message.documentErrors[i] = $root.google.rpc.Status.fromObject(object.documentErrors[i]); + } + } + if (object.datasetErrors) { + if (!Array.isArray(object.datasetErrors)) + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.datasetErrors: array expected"); + message.datasetErrors = []; + for (var i = 0; i < object.datasetErrors.length; ++i) { + if (typeof object.datasetErrors[i] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation.datasetErrors: object expected"); + message.datasetErrors[i] = $root.google.rpc.Status.fromObject(object.datasetErrors[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a DatasetValidation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @static + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation} message DatasetValidation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DatasetValidation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.documentErrors = []; + object.datasetErrors = []; + } + if (options.defaults) { + object.documentErrorCount = 0; + object.datasetErrorCount = 0; + } + if (message.documentErrors && message.documentErrors.length) { + object.documentErrors = []; + for (var j = 0; j < message.documentErrors.length; ++j) + object.documentErrors[j] = $root.google.rpc.Status.toObject(message.documentErrors[j], options); + } + if (message.datasetErrors && message.datasetErrors.length) { + object.datasetErrors = []; + for (var j = 0; j < message.datasetErrors.length; ++j) + object.datasetErrors[j] = $root.google.rpc.Status.toObject(message.datasetErrors[j], options); + } + if (message.documentErrorCount != null && message.hasOwnProperty("documentErrorCount")) + object.documentErrorCount = message.documentErrorCount; + if (message.datasetErrorCount != null && message.hasOwnProperty("datasetErrorCount")) + object.datasetErrorCount = message.datasetErrorCount; + return object; + }; + + /** + * Converts this DatasetValidation to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @instance + * @returns {Object.} JSON object + */ + DatasetValidation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DatasetValidation + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DatasetValidation.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata.DatasetValidation"; + }; + + return DatasetValidation; + })(); + + return TrainProcessorVersionMetadata; + })(); + + v1beta3.ReviewDocumentRequest = (function() { + + /** + * Properties of a ReviewDocumentRequest. + * @memberof google.cloud.documentai.v1beta3 + * @interface IReviewDocumentRequest + * @property {google.cloud.documentai.v1beta3.IDocument|null} [inlineDocument] ReviewDocumentRequest inlineDocument + * @property {string|null} [humanReviewConfig] ReviewDocumentRequest humanReviewConfig + * @property {google.cloud.documentai.v1beta3.IDocument|null} [document] ReviewDocumentRequest document + * @property {boolean|null} [enableSchemaValidation] ReviewDocumentRequest enableSchemaValidation + * @property {google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority|null} [priority] ReviewDocumentRequest priority + * @property {google.cloud.documentai.v1beta3.IDocumentSchema|null} [documentSchema] ReviewDocumentRequest documentSchema + */ + + /** + * Constructs a new ReviewDocumentRequest. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents a ReviewDocumentRequest. + * @implements IReviewDocumentRequest + * @constructor + * @param {google.cloud.documentai.v1beta3.IReviewDocumentRequest=} [properties] Properties to set + */ + function ReviewDocumentRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReviewDocumentRequest inlineDocument. + * @member {google.cloud.documentai.v1beta3.IDocument|null|undefined} inlineDocument + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @instance + */ + ReviewDocumentRequest.prototype.inlineDocument = null; + + /** + * ReviewDocumentRequest humanReviewConfig. + * @member {string} humanReviewConfig + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @instance + */ + ReviewDocumentRequest.prototype.humanReviewConfig = ""; + + /** + * ReviewDocumentRequest document. + * @member {google.cloud.documentai.v1beta3.IDocument|null|undefined} document + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @instance + */ + ReviewDocumentRequest.prototype.document = null; + + /** + * ReviewDocumentRequest enableSchemaValidation. + * @member {boolean} enableSchemaValidation + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @instance + */ + ReviewDocumentRequest.prototype.enableSchemaValidation = false; + + /** + * ReviewDocumentRequest priority. + * @member {google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority} priority + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @instance + */ + ReviewDocumentRequest.prototype.priority = 0; + + /** + * ReviewDocumentRequest documentSchema. + * @member {google.cloud.documentai.v1beta3.IDocumentSchema|null|undefined} documentSchema + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @instance + */ + ReviewDocumentRequest.prototype.documentSchema = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ReviewDocumentRequest source. + * @member {"inlineDocument"|undefined} source + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @instance + */ + Object.defineProperty(ReviewDocumentRequest.prototype, "source", { + get: $util.oneOfGetter($oneOfFields = ["inlineDocument"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ReviewDocumentRequest instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @static + * @param {google.cloud.documentai.v1beta3.IReviewDocumentRequest=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentRequest} ReviewDocumentRequest instance + */ + ReviewDocumentRequest.create = function create(properties) { + return new ReviewDocumentRequest(properties); + }; + + /** + * Encodes the specified ReviewDocumentRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @static + * @param {google.cloud.documentai.v1beta3.IReviewDocumentRequest} message ReviewDocumentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReviewDocumentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.humanReviewConfig != null && Object.hasOwnProperty.call(message, "humanReviewConfig")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.humanReviewConfig); + if (message.document != null && Object.hasOwnProperty.call(message, "document")) + $root.google.cloud.documentai.v1beta3.Document.encode(message.document, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.enableSchemaValidation != null && Object.hasOwnProperty.call(message, "enableSchemaValidation")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.enableSchemaValidation); + if (message.inlineDocument != null && Object.hasOwnProperty.call(message, "inlineDocument")) + $root.google.cloud.documentai.v1beta3.Document.encode(message.inlineDocument, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.priority != null && Object.hasOwnProperty.call(message, "priority")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.priority); + if (message.documentSchema != null && Object.hasOwnProperty.call(message, "documentSchema")) + $root.google.cloud.documentai.v1beta3.DocumentSchema.encode(message.documentSchema, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ReviewDocumentRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @static + * @param {google.cloud.documentai.v1beta3.IReviewDocumentRequest} message ReviewDocumentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReviewDocumentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReviewDocumentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentRequest} ReviewDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReviewDocumentRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 4: { + message.inlineDocument = $root.google.cloud.documentai.v1beta3.Document.decode(reader, reader.uint32()); + break; + } + case 1: { + message.humanReviewConfig = reader.string(); + break; + } + case 2: { + message.document = $root.google.cloud.documentai.v1beta3.Document.decode(reader, reader.uint32()); + break; + } + case 3: { + message.enableSchemaValidation = reader.bool(); + break; + } + case 5: { + message.priority = reader.int32(); + break; + } + case 6: { + message.documentSchema = $root.google.cloud.documentai.v1beta3.DocumentSchema.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReviewDocumentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentRequest} ReviewDocumentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReviewDocumentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReviewDocumentRequest message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReviewDocumentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.inlineDocument != null && message.hasOwnProperty("inlineDocument")) { + properties.source = 1; + { + var error = $root.google.cloud.documentai.v1beta3.Document.verify(message.inlineDocument); + if (error) + return "inlineDocument." + error; + } + } + if (message.humanReviewConfig != null && message.hasOwnProperty("humanReviewConfig")) + if (!$util.isString(message.humanReviewConfig)) + return "humanReviewConfig: string expected"; + if (message.document != null && message.hasOwnProperty("document")) { + var error = $root.google.cloud.documentai.v1beta3.Document.verify(message.document); + if (error) + return "document." + error; + } + if (message.enableSchemaValidation != null && message.hasOwnProperty("enableSchemaValidation")) + if (typeof message.enableSchemaValidation !== "boolean") + return "enableSchemaValidation: boolean expected"; + if (message.priority != null && message.hasOwnProperty("priority")) + switch (message.priority) { + default: + return "priority: enum value expected"; + case 0: + case 1: + break; + } + if (message.documentSchema != null && message.hasOwnProperty("documentSchema")) { + var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.verify(message.documentSchema); + if (error) + return "documentSchema." + error; + } + return null; + }; + + /** + * Creates a ReviewDocumentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentRequest} ReviewDocumentRequest + */ + ReviewDocumentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.ReviewDocumentRequest) + return object; + var message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentRequest(); + if (object.inlineDocument != null) { + if (typeof object.inlineDocument !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentRequest.inlineDocument: object expected"); + message.inlineDocument = $root.google.cloud.documentai.v1beta3.Document.fromObject(object.inlineDocument); + } + if (object.humanReviewConfig != null) + message.humanReviewConfig = String(object.humanReviewConfig); + if (object.document != null) { + if (typeof object.document !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentRequest.document: object expected"); + message.document = $root.google.cloud.documentai.v1beta3.Document.fromObject(object.document); + } + if (object.enableSchemaValidation != null) + message.enableSchemaValidation = Boolean(object.enableSchemaValidation); + switch (object.priority) { + default: + if (typeof object.priority === "number") { + message.priority = object.priority; + break; + } + break; + case "DEFAULT": + case 0: + message.priority = 0; + break; + case "URGENT": + case 1: + message.priority = 1; + break; + } + if (object.documentSchema != null) { + if (typeof object.documentSchema !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentRequest.documentSchema: object expected"); + message.documentSchema = $root.google.cloud.documentai.v1beta3.DocumentSchema.fromObject(object.documentSchema); + } + return message; + }; + + /** + * Creates a plain object from a ReviewDocumentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @static + * @param {google.cloud.documentai.v1beta3.ReviewDocumentRequest} message ReviewDocumentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReviewDocumentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.humanReviewConfig = ""; + object.document = null; + object.enableSchemaValidation = false; + object.priority = options.enums === String ? "DEFAULT" : 0; + object.documentSchema = null; + } + if (message.humanReviewConfig != null && message.hasOwnProperty("humanReviewConfig")) + object.humanReviewConfig = message.humanReviewConfig; + if (message.document != null && message.hasOwnProperty("document")) + object.document = $root.google.cloud.documentai.v1beta3.Document.toObject(message.document, options); + if (message.enableSchemaValidation != null && message.hasOwnProperty("enableSchemaValidation")) + object.enableSchemaValidation = message.enableSchemaValidation; + if (message.inlineDocument != null && message.hasOwnProperty("inlineDocument")) { + object.inlineDocument = $root.google.cloud.documentai.v1beta3.Document.toObject(message.inlineDocument, options); + if (options.oneofs) + object.source = "inlineDocument"; + } + if (message.priority != null && message.hasOwnProperty("priority")) + object.priority = options.enums === String ? $root.google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority[message.priority] === undefined ? message.priority : $root.google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority[message.priority] : message.priority; + if (message.documentSchema != null && message.hasOwnProperty("documentSchema")) + object.documentSchema = $root.google.cloud.documentai.v1beta3.DocumentSchema.toObject(message.documentSchema, options); + return object; + }; + + /** + * Converts this ReviewDocumentRequest to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @instance + * @returns {Object.} JSON object + */ + ReviewDocumentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReviewDocumentRequest + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReviewDocumentRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ReviewDocumentRequest"; + }; + + /** + * Priority enum. + * @name google.cloud.documentai.v1beta3.ReviewDocumentRequest.Priority + * @enum {number} + * @property {number} DEFAULT=0 DEFAULT value + * @property {number} URGENT=1 URGENT value + */ + ReviewDocumentRequest.Priority = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT"] = 0; + values[valuesById[1] = "URGENT"] = 1; + return values; + })(); + + return ReviewDocumentRequest; + })(); + + v1beta3.ReviewDocumentResponse = (function() { + + /** + * Properties of a ReviewDocumentResponse. + * @memberof google.cloud.documentai.v1beta3 + * @interface IReviewDocumentResponse + * @property {string|null} [gcsDestination] ReviewDocumentResponse gcsDestination + * @property {google.cloud.documentai.v1beta3.ReviewDocumentResponse.State|null} [state] ReviewDocumentResponse state + * @property {string|null} [rejectionReason] ReviewDocumentResponse rejectionReason + */ + + /** + * Constructs a new ReviewDocumentResponse. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents a ReviewDocumentResponse. + * @implements IReviewDocumentResponse + * @constructor + * @param {google.cloud.documentai.v1beta3.IReviewDocumentResponse=} [properties] Properties to set + */ + function ReviewDocumentResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReviewDocumentResponse gcsDestination. + * @member {string} gcsDestination + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @instance + */ + ReviewDocumentResponse.prototype.gcsDestination = ""; + + /** + * ReviewDocumentResponse state. + * @member {google.cloud.documentai.v1beta3.ReviewDocumentResponse.State} state + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @instance + */ + ReviewDocumentResponse.prototype.state = 0; + + /** + * ReviewDocumentResponse rejectionReason. + * @member {string} rejectionReason + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @instance + */ + ReviewDocumentResponse.prototype.rejectionReason = ""; + + /** + * Creates a new ReviewDocumentResponse instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @static + * @param {google.cloud.documentai.v1beta3.IReviewDocumentResponse=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentResponse} ReviewDocumentResponse instance + */ + ReviewDocumentResponse.create = function create(properties) { + return new ReviewDocumentResponse(properties); + }; + + /** + * Encodes the specified ReviewDocumentResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @static + * @param {google.cloud.documentai.v1beta3.IReviewDocumentResponse} message ReviewDocumentResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReviewDocumentResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.gcsDestination != null && Object.hasOwnProperty.call(message, "gcsDestination")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.gcsDestination); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.state); + if (message.rejectionReason != null && Object.hasOwnProperty.call(message, "rejectionReason")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.rejectionReason); + return writer; + }; + + /** + * Encodes the specified ReviewDocumentResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @static + * @param {google.cloud.documentai.v1beta3.IReviewDocumentResponse} message ReviewDocumentResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReviewDocumentResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReviewDocumentResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentResponse} ReviewDocumentResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReviewDocumentResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.gcsDestination = reader.string(); + break; + } + case 2: { + message.state = reader.int32(); + break; + } + case 3: { + message.rejectionReason = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReviewDocumentResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentResponse} ReviewDocumentResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReviewDocumentResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReviewDocumentResponse message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReviewDocumentResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.gcsDestination != null && message.hasOwnProperty("gcsDestination")) + if (!$util.isString(message.gcsDestination)) + return "gcsDestination: string expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.rejectionReason != null && message.hasOwnProperty("rejectionReason")) + if (!$util.isString(message.rejectionReason)) + return "rejectionReason: string expected"; + return null; + }; + + /** + * Creates a ReviewDocumentResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentResponse} ReviewDocumentResponse + */ + ReviewDocumentResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.ReviewDocumentResponse) + return object; + var message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentResponse(); + if (object.gcsDestination != null) + message.gcsDestination = String(object.gcsDestination); + switch (object.state) { + default: + if (typeof object.state === "number") { + message.state = object.state; + break; + } + break; + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "REJECTED": + case 1: + message.state = 1; + break; + case "SUCCEEDED": + case 2: + message.state = 2; + break; + } + if (object.rejectionReason != null) + message.rejectionReason = String(object.rejectionReason); + return message; + }; + + /** + * Creates a plain object from a ReviewDocumentResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @static + * @param {google.cloud.documentai.v1beta3.ReviewDocumentResponse} message ReviewDocumentResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReviewDocumentResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.gcsDestination = ""; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + object.rejectionReason = ""; + } + if (message.gcsDestination != null && message.hasOwnProperty("gcsDestination")) + object.gcsDestination = message.gcsDestination; + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.cloud.documentai.v1beta3.ReviewDocumentResponse.State[message.state] === undefined ? message.state : $root.google.cloud.documentai.v1beta3.ReviewDocumentResponse.State[message.state] : message.state; + if (message.rejectionReason != null && message.hasOwnProperty("rejectionReason")) + object.rejectionReason = message.rejectionReason; + return object; + }; + + /** + * Converts this ReviewDocumentResponse to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @instance + * @returns {Object.} JSON object + */ + ReviewDocumentResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReviewDocumentResponse + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReviewDocumentResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ReviewDocumentResponse"; + }; + + /** + * State enum. + * @name google.cloud.documentai.v1beta3.ReviewDocumentResponse.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} REJECTED=1 REJECTED value + * @property {number} SUCCEEDED=2 SUCCEEDED value + */ + ReviewDocumentResponse.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "REJECTED"] = 1; + values[valuesById[2] = "SUCCEEDED"] = 2; + return values; + })(); + + return ReviewDocumentResponse; + })(); + + v1beta3.ReviewDocumentOperationMetadata = (function() { + + /** + * Properties of a ReviewDocumentOperationMetadata. + * @memberof google.cloud.documentai.v1beta3 + * @interface IReviewDocumentOperationMetadata + * @property {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State|null} [state] ReviewDocumentOperationMetadata state + * @property {string|null} [stateMessage] ReviewDocumentOperationMetadata stateMessage + * @property {google.protobuf.ITimestamp|null} [createTime] ReviewDocumentOperationMetadata createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] ReviewDocumentOperationMetadata updateTime + * @property {google.cloud.documentai.v1beta3.ICommonOperationMetadata|null} [commonMetadata] ReviewDocumentOperationMetadata commonMetadata + * @property {string|null} [questionId] ReviewDocumentOperationMetadata questionId + */ + + /** + * Constructs a new ReviewDocumentOperationMetadata. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents a ReviewDocumentOperationMetadata. + * @implements IReviewDocumentOperationMetadata + * @constructor + * @param {google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata=} [properties] Properties to set + */ + function ReviewDocumentOperationMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReviewDocumentOperationMetadata state. + * @member {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State} state + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @instance + */ + ReviewDocumentOperationMetadata.prototype.state = 0; + + /** + * ReviewDocumentOperationMetadata stateMessage. + * @member {string} stateMessage + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @instance + */ + ReviewDocumentOperationMetadata.prototype.stateMessage = ""; + + /** + * ReviewDocumentOperationMetadata createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @instance + */ + ReviewDocumentOperationMetadata.prototype.createTime = null; + + /** + * ReviewDocumentOperationMetadata updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @instance + */ + ReviewDocumentOperationMetadata.prototype.updateTime = null; + + /** + * ReviewDocumentOperationMetadata commonMetadata. + * @member {google.cloud.documentai.v1beta3.ICommonOperationMetadata|null|undefined} commonMetadata + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @instance + */ + ReviewDocumentOperationMetadata.prototype.commonMetadata = null; + + /** + * ReviewDocumentOperationMetadata questionId. + * @member {string} questionId + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @instance + */ + ReviewDocumentOperationMetadata.prototype.questionId = ""; + + /** + * Creates a new ReviewDocumentOperationMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @static + * @param {google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata} ReviewDocumentOperationMetadata instance + */ + ReviewDocumentOperationMetadata.create = function create(properties) { + return new ReviewDocumentOperationMetadata(properties); + }; + + /** + * Encodes the specified ReviewDocumentOperationMetadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @static + * @param {google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata} message ReviewDocumentOperationMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReviewDocumentOperationMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.state); + if (message.stateMessage != null && Object.hasOwnProperty.call(message, "stateMessage")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.stateMessage); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.commonMetadata != null && Object.hasOwnProperty.call(message, "commonMetadata")) + $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.encode(message.commonMetadata, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.questionId != null && Object.hasOwnProperty.call(message, "questionId")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.questionId); + return writer; + }; + + /** + * Encodes the specified ReviewDocumentOperationMetadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @static + * @param {google.cloud.documentai.v1beta3.IReviewDocumentOperationMetadata} message ReviewDocumentOperationMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReviewDocumentOperationMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReviewDocumentOperationMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata} ReviewDocumentOperationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReviewDocumentOperationMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.state = reader.int32(); + break; + } + case 2: { + message.stateMessage = reader.string(); + break; + } + case 3: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 4: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.decode(reader, reader.uint32()); + break; + } + case 6: { + message.questionId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReviewDocumentOperationMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata} ReviewDocumentOperationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReviewDocumentOperationMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReviewDocumentOperationMetadata message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReviewDocumentOperationMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.stateMessage != null && message.hasOwnProperty("stateMessage")) + if (!$util.isString(message.stateMessage)) + return "stateMessage: string expected"; + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + if (message.commonMetadata != null && message.hasOwnProperty("commonMetadata")) { + var error = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.verify(message.commonMetadata); + if (error) + return "commonMetadata." + error; + } + if (message.questionId != null && message.hasOwnProperty("questionId")) + if (!$util.isString(message.questionId)) + return "questionId: string expected"; + return null; + }; + + /** + * Creates a ReviewDocumentOperationMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata} ReviewDocumentOperationMetadata + */ + ReviewDocumentOperationMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata) + return object; + var message = new $root.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata(); + switch (object.state) { + default: + if (typeof object.state === "number") { + message.state = object.state; + break; + } + break; + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "RUNNING": + case 1: + message.state = 1; + break; + case "CANCELLING": + case 2: + message.state = 2; + break; + case "SUCCEEDED": + case 3: + message.state = 3; + break; + case "FAILED": + case 4: + message.state = 4; + break; + case "CANCELLED": + case 5: + message.state = 5; + break; + } + if (object.stateMessage != null) + message.stateMessage = String(object.stateMessage); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.commonMetadata != null) { + if (typeof object.commonMetadata !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.commonMetadata: object expected"); + message.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.fromObject(object.commonMetadata); + } + if (object.questionId != null) + message.questionId = String(object.questionId); + return message; + }; + + /** + * Creates a plain object from a ReviewDocumentOperationMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @static + * @param {google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata} message ReviewDocumentOperationMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReviewDocumentOperationMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + object.stateMessage = ""; + object.createTime = null; + object.updateTime = null; + object.commonMetadata = null; + object.questionId = ""; + } + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State[message.state] === undefined ? message.state : $root.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State[message.state] : message.state; + if (message.stateMessage != null && message.hasOwnProperty("stateMessage")) + object.stateMessage = message.stateMessage; + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.commonMetadata != null && message.hasOwnProperty("commonMetadata")) + object.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.toObject(message.commonMetadata, options); + if (message.questionId != null && message.hasOwnProperty("questionId")) + object.questionId = message.questionId; + return object; + }; + + /** + * Converts this ReviewDocumentOperationMetadata to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @instance + * @returns {Object.} JSON object + */ + ReviewDocumentOperationMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReviewDocumentOperationMetadata + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReviewDocumentOperationMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata"; + }; + + /** + * State enum. + * @name google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} RUNNING=1 RUNNING value + * @property {number} CANCELLING=2 CANCELLING value + * @property {number} SUCCEEDED=3 SUCCEEDED value + * @property {number} FAILED=4 FAILED value + * @property {number} CANCELLED=5 CANCELLED value + */ + ReviewDocumentOperationMetadata.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "RUNNING"] = 1; + values[valuesById[2] = "CANCELLING"] = 2; + values[valuesById[3] = "SUCCEEDED"] = 3; + values[valuesById[4] = "FAILED"] = 4; + values[valuesById[5] = "CANCELLED"] = 5; + return values; + })(); + + return ReviewDocumentOperationMetadata; + })(); + + v1beta3.EvaluateProcessorVersionRequest = (function() { + + /** + * Properties of an EvaluateProcessorVersionRequest. + * @memberof google.cloud.documentai.v1beta3 + * @interface IEvaluateProcessorVersionRequest + * @property {string|null} [processorVersion] EvaluateProcessorVersionRequest processorVersion + * @property {google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null} [evaluationDocuments] EvaluateProcessorVersionRequest evaluationDocuments + */ + + /** + * Constructs a new EvaluateProcessorVersionRequest. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents an EvaluateProcessorVersionRequest. + * @implements IEvaluateProcessorVersionRequest + * @constructor + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest=} [properties] Properties to set + */ + function EvaluateProcessorVersionRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EvaluateProcessorVersionRequest processorVersion. + * @member {string} processorVersion + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @instance + */ + EvaluateProcessorVersionRequest.prototype.processorVersion = ""; + + /** + * EvaluateProcessorVersionRequest evaluationDocuments. + * @member {google.cloud.documentai.v1beta3.IBatchDocumentsInputConfig|null|undefined} evaluationDocuments + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @instance + */ + EvaluateProcessorVersionRequest.prototype.evaluationDocuments = null; + + /** + * Creates a new EvaluateProcessorVersionRequest instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @static + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest} EvaluateProcessorVersionRequest instance + */ + EvaluateProcessorVersionRequest.create = function create(properties) { + return new EvaluateProcessorVersionRequest(properties); + }; + + /** + * Encodes the specified EvaluateProcessorVersionRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @static + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest} message EvaluateProcessorVersionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EvaluateProcessorVersionRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.processorVersion != null && Object.hasOwnProperty.call(message, "processorVersion")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.processorVersion); + if (message.evaluationDocuments != null && Object.hasOwnProperty.call(message, "evaluationDocuments")) + $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.encode(message.evaluationDocuments, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EvaluateProcessorVersionRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @static + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest} message EvaluateProcessorVersionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EvaluateProcessorVersionRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EvaluateProcessorVersionRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest} EvaluateProcessorVersionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EvaluateProcessorVersionRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.processorVersion = reader.string(); + break; + } + case 3: { + message.evaluationDocuments = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EvaluateProcessorVersionRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest} EvaluateProcessorVersionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EvaluateProcessorVersionRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EvaluateProcessorVersionRequest message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EvaluateProcessorVersionRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.processorVersion != null && message.hasOwnProperty("processorVersion")) + if (!$util.isString(message.processorVersion)) + return "processorVersion: string expected"; + if (message.evaluationDocuments != null && message.hasOwnProperty("evaluationDocuments")) { + var error = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.verify(message.evaluationDocuments); + if (error) + return "evaluationDocuments." + error; + } + return null; + }; + + /** + * Creates an EvaluateProcessorVersionRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest} EvaluateProcessorVersionRequest + */ + EvaluateProcessorVersionRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest) + return object; + var message = new $root.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest(); + if (object.processorVersion != null) + message.processorVersion = String(object.processorVersion); + if (object.evaluationDocuments != null) { + if (typeof object.evaluationDocuments !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest.evaluationDocuments: object expected"); + message.evaluationDocuments = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.fromObject(object.evaluationDocuments); + } + return message; + }; + + /** + * Creates a plain object from an EvaluateProcessorVersionRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @static + * @param {google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest} message EvaluateProcessorVersionRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EvaluateProcessorVersionRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.processorVersion = ""; + object.evaluationDocuments = null; + } + if (message.processorVersion != null && message.hasOwnProperty("processorVersion")) + object.processorVersion = message.processorVersion; + if (message.evaluationDocuments != null && message.hasOwnProperty("evaluationDocuments")) + object.evaluationDocuments = $root.google.cloud.documentai.v1beta3.BatchDocumentsInputConfig.toObject(message.evaluationDocuments, options); + return object; + }; + + /** + * Converts this EvaluateProcessorVersionRequest to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @instance + * @returns {Object.} JSON object + */ + EvaluateProcessorVersionRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EvaluateProcessorVersionRequest + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EvaluateProcessorVersionRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest"; + }; + + return EvaluateProcessorVersionRequest; + })(); + + v1beta3.EvaluateProcessorVersionMetadata = (function() { + + /** + * Properties of an EvaluateProcessorVersionMetadata. + * @memberof google.cloud.documentai.v1beta3 + * @interface IEvaluateProcessorVersionMetadata + * @property {google.cloud.documentai.v1beta3.ICommonOperationMetadata|null} [commonMetadata] EvaluateProcessorVersionMetadata commonMetadata + */ + + /** + * Constructs a new EvaluateProcessorVersionMetadata. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents an EvaluateProcessorVersionMetadata. + * @implements IEvaluateProcessorVersionMetadata + * @constructor + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata=} [properties] Properties to set + */ + function EvaluateProcessorVersionMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EvaluateProcessorVersionMetadata commonMetadata. + * @member {google.cloud.documentai.v1beta3.ICommonOperationMetadata|null|undefined} commonMetadata + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @instance + */ + EvaluateProcessorVersionMetadata.prototype.commonMetadata = null; + + /** + * Creates a new EvaluateProcessorVersionMetadata instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @static + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata} EvaluateProcessorVersionMetadata instance + */ + EvaluateProcessorVersionMetadata.create = function create(properties) { + return new EvaluateProcessorVersionMetadata(properties); + }; + + /** + * Encodes the specified EvaluateProcessorVersionMetadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @static + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata} message EvaluateProcessorVersionMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EvaluateProcessorVersionMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.commonMetadata != null && Object.hasOwnProperty.call(message, "commonMetadata")) + $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.encode(message.commonMetadata, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EvaluateProcessorVersionMetadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @static + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata} message EvaluateProcessorVersionMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EvaluateProcessorVersionMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EvaluateProcessorVersionMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata} EvaluateProcessorVersionMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EvaluateProcessorVersionMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EvaluateProcessorVersionMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata} EvaluateProcessorVersionMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EvaluateProcessorVersionMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EvaluateProcessorVersionMetadata message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EvaluateProcessorVersionMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.commonMetadata != null && message.hasOwnProperty("commonMetadata")) { + var error = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.verify(message.commonMetadata); + if (error) + return "commonMetadata." + error; + } + return null; + }; + + /** + * Creates an EvaluateProcessorVersionMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata} EvaluateProcessorVersionMetadata + */ + EvaluateProcessorVersionMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata) + return object; + var message = new $root.google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata(); + if (object.commonMetadata != null) { + if (typeof object.commonMetadata !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata.commonMetadata: object expected"); + message.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.fromObject(object.commonMetadata); + } + return message; + }; + + /** + * Creates a plain object from an EvaluateProcessorVersionMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @static + * @param {google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata} message EvaluateProcessorVersionMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EvaluateProcessorVersionMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.commonMetadata = null; + if (message.commonMetadata != null && message.hasOwnProperty("commonMetadata")) + object.commonMetadata = $root.google.cloud.documentai.v1beta3.CommonOperationMetadata.toObject(message.commonMetadata, options); + return object; + }; + + /** + * Converts this EvaluateProcessorVersionMetadata to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @instance + * @returns {Object.} JSON object + */ + EvaluateProcessorVersionMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EvaluateProcessorVersionMetadata + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EvaluateProcessorVersionMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata"; + }; + + return EvaluateProcessorVersionMetadata; + })(); + + v1beta3.EvaluateProcessorVersionResponse = (function() { + + /** + * Properties of an EvaluateProcessorVersionResponse. + * @memberof google.cloud.documentai.v1beta3 + * @interface IEvaluateProcessorVersionResponse + * @property {string|null} [evaluation] EvaluateProcessorVersionResponse evaluation + */ + + /** + * Constructs a new EvaluateProcessorVersionResponse. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents an EvaluateProcessorVersionResponse. + * @implements IEvaluateProcessorVersionResponse + * @constructor + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse=} [properties] Properties to set + */ + function EvaluateProcessorVersionResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EvaluateProcessorVersionResponse evaluation. + * @member {string} evaluation + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @instance + */ + EvaluateProcessorVersionResponse.prototype.evaluation = ""; + + /** + * Creates a new EvaluateProcessorVersionResponse instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @static + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse} EvaluateProcessorVersionResponse instance + */ + EvaluateProcessorVersionResponse.create = function create(properties) { + return new EvaluateProcessorVersionResponse(properties); + }; + + /** + * Encodes the specified EvaluateProcessorVersionResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @static + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse} message EvaluateProcessorVersionResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EvaluateProcessorVersionResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.evaluation != null && Object.hasOwnProperty.call(message, "evaluation")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.evaluation); + return writer; + }; + + /** + * Encodes the specified EvaluateProcessorVersionResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @static + * @param {google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse} message EvaluateProcessorVersionResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EvaluateProcessorVersionResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EvaluateProcessorVersionResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse} EvaluateProcessorVersionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EvaluateProcessorVersionResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + message.evaluation = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EvaluateProcessorVersionResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse} EvaluateProcessorVersionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EvaluateProcessorVersionResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EvaluateProcessorVersionResponse message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EvaluateProcessorVersionResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.evaluation != null && message.hasOwnProperty("evaluation")) + if (!$util.isString(message.evaluation)) + return "evaluation: string expected"; + return null; + }; + + /** + * Creates an EvaluateProcessorVersionResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse} EvaluateProcessorVersionResponse + */ + EvaluateProcessorVersionResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse) + return object; + var message = new $root.google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse(); + if (object.evaluation != null) + message.evaluation = String(object.evaluation); + return message; + }; + + /** + * Creates a plain object from an EvaluateProcessorVersionResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @static + * @param {google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse} message EvaluateProcessorVersionResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EvaluateProcessorVersionResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.evaluation = ""; + if (message.evaluation != null && message.hasOwnProperty("evaluation")) + object.evaluation = message.evaluation; + return object; + }; + + /** + * Converts this EvaluateProcessorVersionResponse to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @instance + * @returns {Object.} JSON object + */ + EvaluateProcessorVersionResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EvaluateProcessorVersionResponse + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EvaluateProcessorVersionResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse"; + }; + + return EvaluateProcessorVersionResponse; + })(); + + v1beta3.GetEvaluationRequest = (function() { + + /** + * Properties of a GetEvaluationRequest. + * @memberof google.cloud.documentai.v1beta3 + * @interface IGetEvaluationRequest + * @property {string|null} [name] GetEvaluationRequest name + */ + + /** + * Constructs a new GetEvaluationRequest. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents a GetEvaluationRequest. + * @implements IGetEvaluationRequest + * @constructor + * @param {google.cloud.documentai.v1beta3.IGetEvaluationRequest=} [properties] Properties to set + */ + function GetEvaluationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetEvaluationRequest name. + * @member {string} name + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @instance + */ + GetEvaluationRequest.prototype.name = ""; + + /** + * Creates a new GetEvaluationRequest instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @static + * @param {google.cloud.documentai.v1beta3.IGetEvaluationRequest=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.GetEvaluationRequest} GetEvaluationRequest instance + */ + GetEvaluationRequest.create = function create(properties) { + return new GetEvaluationRequest(properties); + }; + + /** + * Encodes the specified GetEvaluationRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.GetEvaluationRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @static + * @param {google.cloud.documentai.v1beta3.IGetEvaluationRequest} message GetEvaluationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetEvaluationRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified GetEvaluationRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.GetEvaluationRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @static + * @param {google.cloud.documentai.v1beta3.IGetEvaluationRequest} message GetEvaluationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetEvaluationRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetEvaluationRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.GetEvaluationRequest} GetEvaluationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetEvaluationRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.GetEvaluationRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetEvaluationRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.GetEvaluationRequest} GetEvaluationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetEvaluationRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetEvaluationRequest message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetEvaluationRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a GetEvaluationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.GetEvaluationRequest} GetEvaluationRequest + */ + GetEvaluationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.GetEvaluationRequest) + return object; + var message = new $root.google.cloud.documentai.v1beta3.GetEvaluationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetEvaluationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @static + * @param {google.cloud.documentai.v1beta3.GetEvaluationRequest} message GetEvaluationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetEvaluationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetEvaluationRequest to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @instance + * @returns {Object.} JSON object + */ + GetEvaluationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetEvaluationRequest + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.GetEvaluationRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetEvaluationRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.GetEvaluationRequest"; + }; + + return GetEvaluationRequest; + })(); + + v1beta3.ListEvaluationsRequest = (function() { + + /** + * Properties of a ListEvaluationsRequest. + * @memberof google.cloud.documentai.v1beta3 + * @interface IListEvaluationsRequest + * @property {string|null} [parent] ListEvaluationsRequest parent + * @property {number|null} [pageSize] ListEvaluationsRequest pageSize + * @property {string|null} [pageToken] ListEvaluationsRequest pageToken + */ + + /** + * Constructs a new ListEvaluationsRequest. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents a ListEvaluationsRequest. + * @implements IListEvaluationsRequest + * @constructor + * @param {google.cloud.documentai.v1beta3.IListEvaluationsRequest=} [properties] Properties to set + */ + function ListEvaluationsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListEvaluationsRequest parent. + * @member {string} parent + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @instance + */ + ListEvaluationsRequest.prototype.parent = ""; + + /** + * ListEvaluationsRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @instance + */ + ListEvaluationsRequest.prototype.pageSize = 0; + + /** + * ListEvaluationsRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @instance + */ + ListEvaluationsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListEvaluationsRequest instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @static + * @param {google.cloud.documentai.v1beta3.IListEvaluationsRequest=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.ListEvaluationsRequest} ListEvaluationsRequest instance + */ + ListEvaluationsRequest.create = function create(properties) { + return new ListEvaluationsRequest(properties); + }; + + /** + * Encodes the specified ListEvaluationsRequest message. Does not implicitly {@link google.cloud.documentai.v1beta3.ListEvaluationsRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @static + * @param {google.cloud.documentai.v1beta3.IListEvaluationsRequest} message ListEvaluationsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListEvaluationsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + return writer; + }; + + /** + * Encodes the specified ListEvaluationsRequest message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ListEvaluationsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @static + * @param {google.cloud.documentai.v1beta3.IListEvaluationsRequest} message ListEvaluationsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListEvaluationsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListEvaluationsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.ListEvaluationsRequest} ListEvaluationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListEvaluationsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.ListEvaluationsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListEvaluationsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.ListEvaluationsRequest} ListEvaluationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListEvaluationsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListEvaluationsRequest message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListEvaluationsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + return null; + }; + + /** + * Creates a ListEvaluationsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.ListEvaluationsRequest} ListEvaluationsRequest + */ + ListEvaluationsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.ListEvaluationsRequest) + return object; + var message = new $root.google.cloud.documentai.v1beta3.ListEvaluationsRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListEvaluationsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @static + * @param {google.cloud.documentai.v1beta3.ListEvaluationsRequest} message ListEvaluationsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListEvaluationsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListEvaluationsRequest to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @instance + * @returns {Object.} JSON object + */ + ListEvaluationsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListEvaluationsRequest + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListEvaluationsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ListEvaluationsRequest"; + }; + + return ListEvaluationsRequest; + })(); + + v1beta3.ListEvaluationsResponse = (function() { + + /** + * Properties of a ListEvaluationsResponse. + * @memberof google.cloud.documentai.v1beta3 + * @interface IListEvaluationsResponse + * @property {Array.|null} [evaluations] ListEvaluationsResponse evaluations + * @property {string|null} [nextPageToken] ListEvaluationsResponse nextPageToken + */ + + /** + * Constructs a new ListEvaluationsResponse. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents a ListEvaluationsResponse. + * @implements IListEvaluationsResponse + * @constructor + * @param {google.cloud.documentai.v1beta3.IListEvaluationsResponse=} [properties] Properties to set + */ + function ListEvaluationsResponse(properties) { + this.evaluations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListEvaluationsResponse evaluations. + * @member {Array.} evaluations + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @instance + */ + ListEvaluationsResponse.prototype.evaluations = $util.emptyArray; + + /** + * ListEvaluationsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @instance + */ + ListEvaluationsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListEvaluationsResponse instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @static + * @param {google.cloud.documentai.v1beta3.IListEvaluationsResponse=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.ListEvaluationsResponse} ListEvaluationsResponse instance + */ + ListEvaluationsResponse.create = function create(properties) { + return new ListEvaluationsResponse(properties); + }; + + /** + * Encodes the specified ListEvaluationsResponse message. Does not implicitly {@link google.cloud.documentai.v1beta3.ListEvaluationsResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @static + * @param {google.cloud.documentai.v1beta3.IListEvaluationsResponse} message ListEvaluationsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListEvaluationsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.evaluations != null && message.evaluations.length) + for (var i = 0; i < message.evaluations.length; ++i) + $root.google.cloud.documentai.v1beta3.Evaluation.encode(message.evaluations[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListEvaluationsResponse message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.ListEvaluationsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @static + * @param {google.cloud.documentai.v1beta3.IListEvaluationsResponse} message ListEvaluationsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListEvaluationsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListEvaluationsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.ListEvaluationsResponse} ListEvaluationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListEvaluationsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.ListEvaluationsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.evaluations && message.evaluations.length)) + message.evaluations = []; + message.evaluations.push($root.google.cloud.documentai.v1beta3.Evaluation.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListEvaluationsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.ListEvaluationsResponse} ListEvaluationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListEvaluationsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListEvaluationsResponse message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListEvaluationsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.evaluations != null && message.hasOwnProperty("evaluations")) { + if (!Array.isArray(message.evaluations)) + return "evaluations: array expected"; + for (var i = 0; i < message.evaluations.length; ++i) { + var error = $root.google.cloud.documentai.v1beta3.Evaluation.verify(message.evaluations[i]); + if (error) + return "evaluations." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListEvaluationsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.ListEvaluationsResponse} ListEvaluationsResponse + */ + ListEvaluationsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.ListEvaluationsResponse) + return object; + var message = new $root.google.cloud.documentai.v1beta3.ListEvaluationsResponse(); + if (object.evaluations) { + if (!Array.isArray(object.evaluations)) + throw TypeError(".google.cloud.documentai.v1beta3.ListEvaluationsResponse.evaluations: array expected"); + message.evaluations = []; + for (var i = 0; i < object.evaluations.length; ++i) { + if (typeof object.evaluations[i] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.ListEvaluationsResponse.evaluations: object expected"); + message.evaluations[i] = $root.google.cloud.documentai.v1beta3.Evaluation.fromObject(object.evaluations[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListEvaluationsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @static + * @param {google.cloud.documentai.v1beta3.ListEvaluationsResponse} message ListEvaluationsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListEvaluationsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.evaluations = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.evaluations && message.evaluations.length) { + object.evaluations = []; + for (var j = 0; j < message.evaluations.length; ++j) + object.evaluations[j] = $root.google.cloud.documentai.v1beta3.Evaluation.toObject(message.evaluations[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListEvaluationsResponse to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @instance + * @returns {Object.} JSON object + */ + ListEvaluationsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListEvaluationsResponse + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.ListEvaluationsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListEvaluationsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ListEvaluationsResponse"; + }; + + return ListEvaluationsResponse; + })(); + + v1beta3.DocumentSchema = (function() { + + /** + * Properties of a DocumentSchema. + * @memberof google.cloud.documentai.v1beta3 + * @interface IDocumentSchema + * @property {string|null} [displayName] DocumentSchema displayName + * @property {string|null} [description] DocumentSchema description + * @property {Array.|null} [entityTypes] DocumentSchema entityTypes + * @property {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata|null} [metadata] DocumentSchema metadata + */ + + /** + * Constructs a new DocumentSchema. + * @memberof google.cloud.documentai.v1beta3 + * @classdesc Represents a DocumentSchema. + * @implements IDocumentSchema + * @constructor + * @param {google.cloud.documentai.v1beta3.IDocumentSchema=} [properties] Properties to set + */ + function DocumentSchema(properties) { + this.entityTypes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DocumentSchema displayName. + * @member {string} displayName + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @instance + */ + DocumentSchema.prototype.displayName = ""; + + /** + * DocumentSchema description. + * @member {string} description + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @instance + */ + DocumentSchema.prototype.description = ""; + + /** + * DocumentSchema entityTypes. + * @member {Array.} entityTypes + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @instance + */ + DocumentSchema.prototype.entityTypes = $util.emptyArray; + + /** + * DocumentSchema metadata. + * @member {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata|null|undefined} metadata + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @instance + */ + DocumentSchema.prototype.metadata = null; + + /** + * Creates a new DocumentSchema instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @static + * @param {google.cloud.documentai.v1beta3.IDocumentSchema=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.DocumentSchema} DocumentSchema instance + */ + DocumentSchema.create = function create(properties) { + return new DocumentSchema(properties); + }; + + /** + * Encodes the specified DocumentSchema message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @static + * @param {google.cloud.documentai.v1beta3.IDocumentSchema} message DocumentSchema message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentSchema.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayName); + if (message.description != null && Object.hasOwnProperty.call(message, "description")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.description); + if (message.entityTypes != null && message.entityTypes.length) + for (var i = 0; i < message.entityTypes.length; ++i) + $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.encode(message.entityTypes[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata.encode(message.metadata, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DocumentSchema message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @static + * @param {google.cloud.documentai.v1beta3.IDocumentSchema} message DocumentSchema message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DocumentSchema.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DocumentSchema message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.DocumentSchema} DocumentSchema + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentSchema.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.DocumentSchema(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.displayName = reader.string(); + break; + } + case 2: { + message.description = reader.string(); + break; + } + case 3: { + if (!(message.entityTypes && message.entityTypes.length)) + message.entityTypes = []; + message.entityTypes.push($root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.decode(reader, reader.uint32())); + break; + } + case 4: { + message.metadata = $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DocumentSchema message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.DocumentSchema} DocumentSchema + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DocumentSchema.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DocumentSchema message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DocumentSchema.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.description != null && message.hasOwnProperty("description")) + if (!$util.isString(message.description)) + return "description: string expected"; + if (message.entityTypes != null && message.hasOwnProperty("entityTypes")) { + if (!Array.isArray(message.entityTypes)) + return "entityTypes: array expected"; + for (var i = 0; i < message.entityTypes.length; ++i) { + var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.verify(message.entityTypes[i]); + if (error) + return "entityTypes." + error; + } + } + if (message.metadata != null && message.hasOwnProperty("metadata")) { + var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata.verify(message.metadata); + if (error) + return "metadata." + error; + } + return null; + }; + + /** + * Creates a DocumentSchema message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.DocumentSchema} DocumentSchema + */ + DocumentSchema.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.DocumentSchema) + return object; + var message = new $root.google.cloud.documentai.v1beta3.DocumentSchema(); + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.description != null) + message.description = String(object.description); + if (object.entityTypes) { + if (!Array.isArray(object.entityTypes)) + throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.entityTypes: array expected"); + message.entityTypes = []; + for (var i = 0; i < object.entityTypes.length; ++i) { + if (typeof object.entityTypes[i] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.entityTypes: object expected"); + message.entityTypes[i] = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.fromObject(object.entityTypes[i]); + } + } + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.metadata: object expected"); + message.metadata = $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata.fromObject(object.metadata); + } + return message; + }; + + /** + * Creates a plain object from a DocumentSchema message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema} message DocumentSchema + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DocumentSchema.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.entityTypes = []; + if (options.defaults) { + object.displayName = ""; + object.description = ""; + object.metadata = null; + } + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.description != null && message.hasOwnProperty("description")) + object.description = message.description; + if (message.entityTypes && message.entityTypes.length) { + object.entityTypes = []; + for (var j = 0; j < message.entityTypes.length; ++j) + object.entityTypes[j] = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.toObject(message.entityTypes[j], options); + } + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata.toObject(message.metadata, options); + return object; + }; + + /** + * Converts this DocumentSchema to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @instance + * @returns {Object.} JSON object + */ + DocumentSchema.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DocumentSchema + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DocumentSchema.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.DocumentSchema"; + }; + + DocumentSchema.EntityType = (function() { + + /** + * Properties of an EntityType. + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @interface IEntityType + * @property {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues|null} [enumValues] EntityType enumValues + * @property {string|null} [displayName] EntityType displayName + * @property {string|null} [name] EntityType name + * @property {Array.|null} [baseTypes] EntityType baseTypes + * @property {Array.|null} [properties] EntityType properties + */ + + /** + * Constructs a new EntityType. + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @classdesc Represents an EntityType. + * @implements IEntityType + * @constructor + * @param {google.cloud.documentai.v1beta3.DocumentSchema.IEntityType=} [properties] Properties to set + */ + function EntityType(properties) { + this.baseTypes = []; + this.properties = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EntityType enumValues. + * @member {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues|null|undefined} enumValues + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @instance + */ + EntityType.prototype.enumValues = null; + + /** + * EntityType displayName. + * @member {string} displayName + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @instance + */ + EntityType.prototype.displayName = ""; + + /** + * EntityType name. + * @member {string} name + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @instance + */ + EntityType.prototype.name = ""; + + /** + * EntityType baseTypes. + * @member {Array.} baseTypes + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @instance + */ + EntityType.prototype.baseTypes = $util.emptyArray; + + /** + * EntityType properties. + * @member {Array.} properties + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @instance + */ + EntityType.prototype.properties = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * EntityType valueSource. + * @member {"enumValues"|undefined} valueSource + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @instance + */ + Object.defineProperty(EntityType.prototype, "valueSource", { + get: $util.oneOfGetter($oneOfFields = ["enumValues"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new EntityType instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.IEntityType=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType} EntityType instance + */ + EntityType.create = function create(properties) { + return new EntityType(properties); + }; + + /** + * Encodes the specified EntityType message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.IEntityType} message EntityType message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EntityType.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.baseTypes != null && message.baseTypes.length) + for (var i = 0; i < message.baseTypes.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.baseTypes[i]); + if (message.properties != null && message.properties.length) + for (var i = 0; i < message.properties.length; ++i) + $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.encode(message.properties[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.displayName); + if (message.enumValues != null && Object.hasOwnProperty.call(message, "enumValues")) + $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.encode(message.enumValues, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EntityType message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.IEntityType} message EntityType message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EntityType.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EntityType message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType} EntityType + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EntityType.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 14: { + message.enumValues = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.decode(reader, reader.uint32()); + break; + } + case 13: { + message.displayName = reader.string(); + break; + } + case 1: { + message.name = reader.string(); + break; + } + case 2: { + if (!(message.baseTypes && message.baseTypes.length)) + message.baseTypes = []; + message.baseTypes.push(reader.string()); + break; + } + case 6: { + if (!(message.properties && message.properties.length)) + message.properties = []; + message.properties.push($root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EntityType message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType} EntityType + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EntityType.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EntityType message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EntityType.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.enumValues != null && message.hasOwnProperty("enumValues")) { + properties.valueSource = 1; + { + var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.verify(message.enumValues); + if (error) + return "enumValues." + error; + } + } + if (message.displayName != null && message.hasOwnProperty("displayName")) + if (!$util.isString(message.displayName)) + return "displayName: string expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.baseTypes != null && message.hasOwnProperty("baseTypes")) { + if (!Array.isArray(message.baseTypes)) + return "baseTypes: array expected"; + for (var i = 0; i < message.baseTypes.length; ++i) + if (!$util.isString(message.baseTypes[i])) + return "baseTypes: string[] expected"; + } + if (message.properties != null && message.hasOwnProperty("properties")) { + if (!Array.isArray(message.properties)) + return "properties: array expected"; + for (var i = 0; i < message.properties.length; ++i) { + var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.verify(message.properties[i]); + if (error) + return "properties." + error; + } + } + return null; + }; + + /** + * Creates an EntityType message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType} EntityType + */ + EntityType.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType) + return object; + var message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType(); + if (object.enumValues != null) { + if (typeof object.enumValues !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.EntityType.enumValues: object expected"); + message.enumValues = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.fromObject(object.enumValues); + } + if (object.displayName != null) + message.displayName = String(object.displayName); + if (object.name != null) + message.name = String(object.name); + if (object.baseTypes) { + if (!Array.isArray(object.baseTypes)) + throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.EntityType.baseTypes: array expected"); + message.baseTypes = []; + for (var i = 0; i < object.baseTypes.length; ++i) + message.baseTypes[i] = String(object.baseTypes[i]); + } + if (object.properties) { + if (!Array.isArray(object.properties)) + throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.EntityType.properties: array expected"); + message.properties = []; + for (var i = 0; i < object.properties.length; ++i) { + if (typeof object.properties[i] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.EntityType.properties: object expected"); + message.properties[i] = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.fromObject(object.properties[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an EntityType message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType} message EntityType + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EntityType.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.baseTypes = []; + object.properties = []; + } + if (options.defaults) { + object.name = ""; + object.displayName = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.baseTypes && message.baseTypes.length) { + object.baseTypes = []; + for (var j = 0; j < message.baseTypes.length; ++j) + object.baseTypes[j] = message.baseTypes[j]; + } + if (message.properties && message.properties.length) { + object.properties = []; + for (var j = 0; j < message.properties.length; ++j) + object.properties[j] = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.toObject(message.properties[j], options); + } + if (message.displayName != null && message.hasOwnProperty("displayName")) + object.displayName = message.displayName; + if (message.enumValues != null && message.hasOwnProperty("enumValues")) { + object.enumValues = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.toObject(message.enumValues, options); + if (options.oneofs) + object.valueSource = "enumValues"; + } + return object; + }; + + /** + * Converts this EntityType to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @instance + * @returns {Object.} JSON object + */ + EntityType.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EntityType + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EntityType.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.DocumentSchema.EntityType"; + }; + + EntityType.EnumValues = (function() { + + /** + * Properties of an EnumValues. + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @interface IEnumValues + * @property {Array.|null} [values] EnumValues values + */ + + /** + * Constructs a new EnumValues. + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @classdesc Represents an EnumValues. + * @implements IEnumValues + * @constructor + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues=} [properties] Properties to set + */ + function EnumValues(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValues values. + * @member {Array.} values + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @instance + */ + EnumValues.prototype.values = $util.emptyArray; + + /** + * Creates a new EnumValues instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues} EnumValues instance + */ + EnumValues.create = function create(properties) { + return new EnumValues(properties); + }; + + /** + * Encodes the specified EnumValues message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues} message EnumValues message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValues.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.values != null && message.values.length) + for (var i = 0; i < message.values.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.values[i]); + return writer; + }; + + /** + * Encodes the specified EnumValues message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues} message EnumValues message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValues.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EnumValues message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues} EnumValues + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValues.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.values && message.values.length)) + message.values = []; + message.values.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EnumValues message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues} EnumValues + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValues.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EnumValues message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValues.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.values != null && message.hasOwnProperty("values")) { + if (!Array.isArray(message.values)) + return "values: array expected"; + for (var i = 0; i < message.values.length; ++i) + if (!$util.isString(message.values[i])) + return "values: string[] expected"; + } + return null; + }; + + /** + * Creates an EnumValues message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues} EnumValues + */ + EnumValues.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues) + return object; + var message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues(); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) + message.values[i] = String(object.values[i]); + } + return message; + }; + + /** + * Creates a plain object from an EnumValues message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues} message EnumValues + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValues.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = message.values[j]; + } + return object; + }; + + /** + * Converts this EnumValues to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @instance + * @returns {Object.} JSON object + */ + EnumValues.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EnumValues + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumValues.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues"; + }; + + return EnumValues; + })(); + + EntityType.Property = (function() { + + /** + * Properties of a Property. + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @interface IProperty + * @property {string|null} [name] Property name + * @property {string|null} [valueType] Property valueType + * @property {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType|null} [occurrenceType] Property occurrenceType + */ + + /** + * Constructs a new Property. + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @classdesc Represents a Property. + * @implements IProperty + * @constructor + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty=} [properties] Properties to set + */ + function Property(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Property name. + * @member {string} name + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @instance + */ + Property.prototype.name = ""; + + /** + * Property valueType. + * @member {string} valueType + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @instance + */ + Property.prototype.valueType = ""; + + /** + * Property occurrenceType. + * @member {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType} occurrenceType + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @instance + */ + Property.prototype.occurrenceType = 0; + + /** + * Creates a new Property instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property} Property instance + */ + Property.create = function create(properties) { + return new Property(properties); + }; + + /** + * Encodes the specified Property message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty} message Property message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Property.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.valueType != null && Object.hasOwnProperty.call(message, "valueType")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.valueType); + if (message.occurrenceType != null && Object.hasOwnProperty.call(message, "occurrenceType")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.occurrenceType); + return writer; + }; + + /** + * Encodes the specified Property message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty} message Property message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Property.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Property message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property} Property + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Property.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.valueType = reader.string(); + break; + } + case 3: { + message.occurrenceType = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Property message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property} Property + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Property.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Property message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Property.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.valueType != null && message.hasOwnProperty("valueType")) + if (!$util.isString(message.valueType)) + return "valueType: string expected"; + if (message.occurrenceType != null && message.hasOwnProperty("occurrenceType")) + switch (message.occurrenceType) { + default: + return "occurrenceType: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + return null; + }; + + /** + * Creates a Property message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property} Property + */ + Property.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property) + return object; + var message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property(); + if (object.name != null) + message.name = String(object.name); + if (object.valueType != null) + message.valueType = String(object.valueType); + switch (object.occurrenceType) { + default: + if (typeof object.occurrenceType === "number") { + message.occurrenceType = object.occurrenceType; + break; + } + break; + case "OCCURRENCE_TYPE_UNSPECIFIED": + case 0: + message.occurrenceType = 0; + break; + case "OPTIONAL_ONCE": + case 1: + message.occurrenceType = 1; + break; + case "OPTIONAL_MULTIPLE": + case 2: + message.occurrenceType = 2; + break; + case "REQUIRED_ONCE": + case 3: + message.occurrenceType = 3; + break; + case "REQUIRED_MULTIPLE": + case 4: + message.occurrenceType = 4; + break; + } + return message; + }; + + /** + * Creates a plain object from a Property message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property} message Property + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Property.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.valueType = ""; + object.occurrenceType = options.enums === String ? "OCCURRENCE_TYPE_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.valueType != null && message.hasOwnProperty("valueType")) + object.valueType = message.valueType; + if (message.occurrenceType != null && message.hasOwnProperty("occurrenceType")) + object.occurrenceType = options.enums === String ? $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType[message.occurrenceType] === undefined ? message.occurrenceType : $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType[message.occurrenceType] : message.occurrenceType; + return object; + }; + + /** + * Converts this Property to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @instance + * @returns {Object.} JSON object + */ + Property.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Property + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Property.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property"; + }; + + /** + * OccurrenceType enum. + * @name google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType + * @enum {number} + * @property {number} OCCURRENCE_TYPE_UNSPECIFIED=0 OCCURRENCE_TYPE_UNSPECIFIED value + * @property {number} OPTIONAL_ONCE=1 OPTIONAL_ONCE value + * @property {number} OPTIONAL_MULTIPLE=2 OPTIONAL_MULTIPLE value + * @property {number} REQUIRED_ONCE=3 REQUIRED_ONCE value + * @property {number} REQUIRED_MULTIPLE=4 REQUIRED_MULTIPLE value + */ + Property.OccurrenceType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OCCURRENCE_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "OPTIONAL_ONCE"] = 1; + values[valuesById[2] = "OPTIONAL_MULTIPLE"] = 2; + values[valuesById[3] = "REQUIRED_ONCE"] = 3; + values[valuesById[4] = "REQUIRED_MULTIPLE"] = 4; + return values; + })(); + + return Property; + })(); + + return EntityType; + })(); + + DocumentSchema.Metadata = (function() { + + /** + * Properties of a Metadata. + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @interface IMetadata + * @property {boolean|null} [documentSplitter] Metadata documentSplitter + * @property {boolean|null} [documentAllowMultipleLabels] Metadata documentAllowMultipleLabels + * @property {boolean|null} [prefixedNamingOnProperties] Metadata prefixedNamingOnProperties + * @property {boolean|null} [skipNamingValidation] Metadata skipNamingValidation + */ + + /** + * Constructs a new Metadata. + * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @classdesc Represents a Metadata. + * @implements IMetadata + * @constructor + * @param {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata=} [properties] Properties to set + */ + function Metadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Metadata documentSplitter. + * @member {boolean} documentSplitter + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @instance + */ + Metadata.prototype.documentSplitter = false; + + /** + * Metadata documentAllowMultipleLabels. + * @member {boolean} documentAllowMultipleLabels + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @instance + */ + Metadata.prototype.documentAllowMultipleLabels = false; + + /** + * Metadata prefixedNamingOnProperties. + * @member {boolean} prefixedNamingOnProperties + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @instance + */ + Metadata.prototype.prefixedNamingOnProperties = false; + + /** + * Metadata skipNamingValidation. + * @member {boolean} skipNamingValidation + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @instance + */ + Metadata.prototype.skipNamingValidation = false; + + /** + * Creates a new Metadata instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.Metadata} Metadata instance + */ + Metadata.create = function create(properties) { + return new Metadata(properties); + }; + + /** + * Encodes the specified Metadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.Metadata.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata} message Metadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Metadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.documentSplitter != null && Object.hasOwnProperty.call(message, "documentSplitter")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.documentSplitter); + if (message.documentAllowMultipleLabels != null && Object.hasOwnProperty.call(message, "documentAllowMultipleLabels")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.documentAllowMultipleLabels); + if (message.prefixedNamingOnProperties != null && Object.hasOwnProperty.call(message, "prefixedNamingOnProperties")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.prefixedNamingOnProperties); + if (message.skipNamingValidation != null && Object.hasOwnProperty.call(message, "skipNamingValidation")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.skipNamingValidation); + return writer; + }; + + /** + * Encodes the specified Metadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.Metadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata} message Metadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Metadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Metadata message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.Metadata} Metadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Metadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.documentSplitter = reader.bool(); + break; + } + case 2: { + message.documentAllowMultipleLabels = reader.bool(); + break; + } + case 6: { + message.prefixedNamingOnProperties = reader.bool(); + break; + } + case 7: { + message.skipNamingValidation = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Metadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.Metadata} Metadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Metadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Metadata message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Metadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.documentSplitter != null && message.hasOwnProperty("documentSplitter")) + if (typeof message.documentSplitter !== "boolean") + return "documentSplitter: boolean expected"; + if (message.documentAllowMultipleLabels != null && message.hasOwnProperty("documentAllowMultipleLabels")) + if (typeof message.documentAllowMultipleLabels !== "boolean") + return "documentAllowMultipleLabels: boolean expected"; + if (message.prefixedNamingOnProperties != null && message.hasOwnProperty("prefixedNamingOnProperties")) + if (typeof message.prefixedNamingOnProperties !== "boolean") + return "prefixedNamingOnProperties: boolean expected"; + if (message.skipNamingValidation != null && message.hasOwnProperty("skipNamingValidation")) + if (typeof message.skipNamingValidation !== "boolean") + return "skipNamingValidation: boolean expected"; + return null; + }; + + /** + * Creates a Metadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.DocumentSchema.Metadata} Metadata + */ + Metadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata) + return object; + var message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata(); + if (object.documentSplitter != null) + message.documentSplitter = Boolean(object.documentSplitter); + if (object.documentAllowMultipleLabels != null) + message.documentAllowMultipleLabels = Boolean(object.documentAllowMultipleLabels); + if (object.prefixedNamingOnProperties != null) + message.prefixedNamingOnProperties = Boolean(object.prefixedNamingOnProperties); + if (object.skipNamingValidation != null) + message.skipNamingValidation = Boolean(object.skipNamingValidation); + return message; + }; + + /** + * Creates a plain object from a Metadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @static + * @param {google.cloud.documentai.v1beta3.DocumentSchema.Metadata} message Metadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Metadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.documentSplitter = false; + object.documentAllowMultipleLabels = false; + object.prefixedNamingOnProperties = false; + object.skipNamingValidation = false; + } + if (message.documentSplitter != null && message.hasOwnProperty("documentSplitter")) + object.documentSplitter = message.documentSplitter; + if (message.documentAllowMultipleLabels != null && message.hasOwnProperty("documentAllowMultipleLabels")) + object.documentAllowMultipleLabels = message.documentAllowMultipleLabels; + if (message.prefixedNamingOnProperties != null && message.hasOwnProperty("prefixedNamingOnProperties")) + object.prefixedNamingOnProperties = message.prefixedNamingOnProperties; + if (message.skipNamingValidation != null && message.hasOwnProperty("skipNamingValidation")) + object.skipNamingValidation = message.skipNamingValidation; + return object; + }; - /** - * Gets the default type url for ReviewDocumentOperationMetadata - * @function getTypeUrl - * @memberof google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata - * @static - * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns {string} The default type url - */ - ReviewDocumentOperationMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { - if (typeUrlPrefix === undefined) { - typeUrlPrefix = "type.googleapis.com"; - } - return typeUrlPrefix + "/google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata"; - }; + /** + * Converts this Metadata to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @instance + * @returns {Object.} JSON object + */ + Metadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; - /** - * State enum. - * @name google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata.State - * @enum {number} - * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value - * @property {number} RUNNING=1 RUNNING value - * @property {number} CANCELLING=2 CANCELLING value - * @property {number} SUCCEEDED=3 SUCCEEDED value - * @property {number} FAILED=4 FAILED value - * @property {number} CANCELLED=5 CANCELLED value - */ - ReviewDocumentOperationMetadata.State = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; - values[valuesById[1] = "RUNNING"] = 1; - values[valuesById[2] = "CANCELLING"] = 2; - values[valuesById[3] = "SUCCEEDED"] = 3; - values[valuesById[4] = "FAILED"] = 4; - values[valuesById[5] = "CANCELLED"] = 5; - return values; + /** + * Gets the default type url for Metadata + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Metadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.DocumentSchema.Metadata"; + }; + + return Metadata; })(); - return ReviewDocumentOperationMetadata; + return DocumentSchema; })(); - v1beta3.DocumentSchema = (function() { + v1beta3.Evaluation = (function() { /** - * Properties of a DocumentSchema. + * Properties of an Evaluation. * @memberof google.cloud.documentai.v1beta3 - * @interface IDocumentSchema - * @property {string|null} [displayName] DocumentSchema displayName - * @property {string|null} [description] DocumentSchema description - * @property {Array.|null} [entityTypes] DocumentSchema entityTypes - * @property {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata|null} [metadata] DocumentSchema metadata + * @interface IEvaluation + * @property {string|null} [name] Evaluation name + * @property {google.protobuf.ITimestamp|null} [createTime] Evaluation createTime + * @property {google.cloud.documentai.v1beta3.Evaluation.ICounters|null} [documentCounters] Evaluation documentCounters + * @property {google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics|null} [allEntitiesMetrics] Evaluation allEntitiesMetrics + * @property {Object.|null} [entityMetrics] Evaluation entityMetrics + * @property {string|null} [kmsKeyName] Evaluation kmsKeyName + * @property {string|null} [kmsKeyVersionName] Evaluation kmsKeyVersionName */ /** - * Constructs a new DocumentSchema. + * Constructs a new Evaluation. * @memberof google.cloud.documentai.v1beta3 - * @classdesc Represents a DocumentSchema. - * @implements IDocumentSchema + * @classdesc Represents an Evaluation. + * @implements IEvaluation * @constructor - * @param {google.cloud.documentai.v1beta3.IDocumentSchema=} [properties] Properties to set + * @param {google.cloud.documentai.v1beta3.IEvaluation=} [properties] Properties to set */ - function DocumentSchema(properties) { - this.entityTypes = []; + function Evaluation(properties) { + this.entityMetrics = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -75639,120 +80491,181 @@ } /** - * DocumentSchema displayName. - * @member {string} displayName - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * Evaluation name. + * @member {string} name + * @memberof google.cloud.documentai.v1beta3.Evaluation * @instance */ - DocumentSchema.prototype.displayName = ""; + Evaluation.prototype.name = ""; /** - * DocumentSchema description. - * @member {string} description - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * Evaluation createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.cloud.documentai.v1beta3.Evaluation * @instance */ - DocumentSchema.prototype.description = ""; + Evaluation.prototype.createTime = null; /** - * DocumentSchema entityTypes. - * @member {Array.} entityTypes - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * Evaluation documentCounters. + * @member {google.cloud.documentai.v1beta3.Evaluation.ICounters|null|undefined} documentCounters + * @memberof google.cloud.documentai.v1beta3.Evaluation * @instance */ - DocumentSchema.prototype.entityTypes = $util.emptyArray; + Evaluation.prototype.documentCounters = null; /** - * DocumentSchema metadata. - * @member {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata|null|undefined} metadata - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * Evaluation allEntitiesMetrics. + * @member {google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics|null|undefined} allEntitiesMetrics + * @memberof google.cloud.documentai.v1beta3.Evaluation * @instance */ - DocumentSchema.prototype.metadata = null; + Evaluation.prototype.allEntitiesMetrics = null; /** - * Creates a new DocumentSchema instance using the specified properties. + * Evaluation entityMetrics. + * @member {Object.} entityMetrics + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @instance + */ + Evaluation.prototype.entityMetrics = $util.emptyObject; + + /** + * Evaluation kmsKeyName. + * @member {string} kmsKeyName + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @instance + */ + Evaluation.prototype.kmsKeyName = ""; + + /** + * Evaluation kmsKeyVersionName. + * @member {string} kmsKeyVersionName + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @instance + */ + Evaluation.prototype.kmsKeyVersionName = ""; + + /** + * Creates a new Evaluation instance using the specified properties. * @function create - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @memberof google.cloud.documentai.v1beta3.Evaluation * @static - * @param {google.cloud.documentai.v1beta3.IDocumentSchema=} [properties] Properties to set - * @returns {google.cloud.documentai.v1beta3.DocumentSchema} DocumentSchema instance + * @param {google.cloud.documentai.v1beta3.IEvaluation=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.Evaluation} Evaluation instance */ - DocumentSchema.create = function create(properties) { - return new DocumentSchema(properties); + Evaluation.create = function create(properties) { + return new Evaluation(properties); }; /** - * Encodes the specified DocumentSchema message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.verify|verify} messages. + * Encodes the specified Evaluation message. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.verify|verify} messages. * @function encode - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @memberof google.cloud.documentai.v1beta3.Evaluation * @static - * @param {google.cloud.documentai.v1beta3.IDocumentSchema} message DocumentSchema message or plain object to encode + * @param {google.cloud.documentai.v1beta3.IEvaluation} message Evaluation message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - DocumentSchema.encode = function encode(message, writer) { + Evaluation.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayName); - if (message.description != null && Object.hasOwnProperty.call(message, "description")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.description); - if (message.entityTypes != null && message.entityTypes.length) - for (var i = 0; i < message.entityTypes.length; ++i) - $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.encode(message.entityTypes[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) - $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata.encode(message.metadata, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.allEntitiesMetrics != null && Object.hasOwnProperty.call(message, "allEntitiesMetrics")) + $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.encode(message.allEntitiesMetrics, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.entityMetrics != null && Object.hasOwnProperty.call(message, "entityMetrics")) + for (var keys = Object.keys(message.entityMetrics), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 4, wireType 2 =*/34).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.encode(message.entityMetrics[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + if (message.documentCounters != null && Object.hasOwnProperty.call(message, "documentCounters")) + $root.google.cloud.documentai.v1beta3.Evaluation.Counters.encode(message.documentCounters, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.kmsKeyName != null && Object.hasOwnProperty.call(message, "kmsKeyName")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.kmsKeyName); + if (message.kmsKeyVersionName != null && Object.hasOwnProperty.call(message, "kmsKeyVersionName")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.kmsKeyVersionName); return writer; }; /** - * Encodes the specified DocumentSchema message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.verify|verify} messages. + * Encodes the specified Evaluation message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.verify|verify} messages. * @function encodeDelimited - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @memberof google.cloud.documentai.v1beta3.Evaluation * @static - * @param {google.cloud.documentai.v1beta3.IDocumentSchema} message DocumentSchema message or plain object to encode + * @param {google.cloud.documentai.v1beta3.IEvaluation} message Evaluation message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - DocumentSchema.encodeDelimited = function encodeDelimited(message, writer) { + Evaluation.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a DocumentSchema message from the specified reader or buffer. + * Decodes an Evaluation message from the specified reader or buffer. * @function decode - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @memberof google.cloud.documentai.v1beta3.Evaluation * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.documentai.v1beta3.DocumentSchema} DocumentSchema + * @returns {google.cloud.documentai.v1beta3.Evaluation} Evaluation * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - DocumentSchema.decode = function decode(reader, length) { + Evaluation.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.DocumentSchema(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Evaluation(), key, value; while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.displayName = reader.string(); + message.name = reader.string(); break; } case 2: { - message.description = reader.string(); + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.documentCounters = $root.google.cloud.documentai.v1beta3.Evaluation.Counters.decode(reader, reader.uint32()); break; } case 3: { - if (!(message.entityTypes && message.entityTypes.length)) - message.entityTypes = []; - message.entityTypes.push($root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.decode(reader, reader.uint32())); + message.allEntitiesMetrics = $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.decode(reader, reader.uint32()); break; } case 4: { - message.metadata = $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata.decode(reader, reader.uint32()); + if (message.entityMetrics === $util.emptyObject) + message.entityMetrics = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.entityMetrics[key] = value; + break; + } + case 6: { + message.kmsKeyName = reader.string(); + break; + } + case 7: { + message.kmsKeyVersionName = reader.string(); break; } default: @@ -75764,173 +80677,206 @@ }; /** - * Decodes a DocumentSchema message from the specified reader or buffer, length delimited. + * Decodes an Evaluation message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @memberof google.cloud.documentai.v1beta3.Evaluation * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.documentai.v1beta3.DocumentSchema} DocumentSchema + * @returns {google.cloud.documentai.v1beta3.Evaluation} Evaluation * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - DocumentSchema.decodeDelimited = function decodeDelimited(reader) { + Evaluation.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a DocumentSchema message. + * Verifies an Evaluation message. * @function verify - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @memberof google.cloud.documentai.v1beta3.Evaluation * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - DocumentSchema.verify = function verify(message) { + Evaluation.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.displayName != null && message.hasOwnProperty("displayName")) - if (!$util.isString(message.displayName)) - return "displayName: string expected"; - if (message.description != null && message.hasOwnProperty("description")) - if (!$util.isString(message.description)) - return "description: string expected"; - if (message.entityTypes != null && message.hasOwnProperty("entityTypes")) { - if (!Array.isArray(message.entityTypes)) - return "entityTypes: array expected"; - for (var i = 0; i < message.entityTypes.length; ++i) { - var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.verify(message.entityTypes[i]); - if (error) - return "entityTypes." + error; - } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; } - if (message.metadata != null && message.hasOwnProperty("metadata")) { - var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata.verify(message.metadata); + if (message.documentCounters != null && message.hasOwnProperty("documentCounters")) { + var error = $root.google.cloud.documentai.v1beta3.Evaluation.Counters.verify(message.documentCounters); if (error) - return "metadata." + error; + return "documentCounters." + error; + } + if (message.allEntitiesMetrics != null && message.hasOwnProperty("allEntitiesMetrics")) { + var error = $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.verify(message.allEntitiesMetrics); + if (error) + return "allEntitiesMetrics." + error; + } + if (message.entityMetrics != null && message.hasOwnProperty("entityMetrics")) { + if (!$util.isObject(message.entityMetrics)) + return "entityMetrics: object expected"; + var key = Object.keys(message.entityMetrics); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.verify(message.entityMetrics[key[i]]); + if (error) + return "entityMetrics." + error; + } } + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + if (!$util.isString(message.kmsKeyName)) + return "kmsKeyName: string expected"; + if (message.kmsKeyVersionName != null && message.hasOwnProperty("kmsKeyVersionName")) + if (!$util.isString(message.kmsKeyVersionName)) + return "kmsKeyVersionName: string expected"; return null; }; /** - * Creates a DocumentSchema message from a plain object. Also converts values to their respective internal types. + * Creates an Evaluation message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @memberof google.cloud.documentai.v1beta3.Evaluation * @static * @param {Object.} object Plain object - * @returns {google.cloud.documentai.v1beta3.DocumentSchema} DocumentSchema + * @returns {google.cloud.documentai.v1beta3.Evaluation} Evaluation */ - DocumentSchema.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.documentai.v1beta3.DocumentSchema) + Evaluation.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.Evaluation) return object; - var message = new $root.google.cloud.documentai.v1beta3.DocumentSchema(); - if (object.displayName != null) - message.displayName = String(object.displayName); - if (object.description != null) - message.description = String(object.description); - if (object.entityTypes) { - if (!Array.isArray(object.entityTypes)) - throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.entityTypes: array expected"); - message.entityTypes = []; - for (var i = 0; i < object.entityTypes.length; ++i) { - if (typeof object.entityTypes[i] !== "object") - throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.entityTypes: object expected"); - message.entityTypes[i] = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.fromObject(object.entityTypes[i]); - } + var message = new $root.google.cloud.documentai.v1beta3.Evaluation(); + if (object.name != null) + message.name = String(object.name); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Evaluation.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); } - if (object.metadata != null) { - if (typeof object.metadata !== "object") - throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.metadata: object expected"); - message.metadata = $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata.fromObject(object.metadata); + if (object.documentCounters != null) { + if (typeof object.documentCounters !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Evaluation.documentCounters: object expected"); + message.documentCounters = $root.google.cloud.documentai.v1beta3.Evaluation.Counters.fromObject(object.documentCounters); + } + if (object.allEntitiesMetrics != null) { + if (typeof object.allEntitiesMetrics !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Evaluation.allEntitiesMetrics: object expected"); + message.allEntitiesMetrics = $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.fromObject(object.allEntitiesMetrics); + } + if (object.entityMetrics) { + if (typeof object.entityMetrics !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Evaluation.entityMetrics: object expected"); + message.entityMetrics = {}; + for (var keys = Object.keys(object.entityMetrics), i = 0; i < keys.length; ++i) { + if (typeof object.entityMetrics[keys[i]] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Evaluation.entityMetrics: object expected"); + message.entityMetrics[keys[i]] = $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.fromObject(object.entityMetrics[keys[i]]); + } } + if (object.kmsKeyName != null) + message.kmsKeyName = String(object.kmsKeyName); + if (object.kmsKeyVersionName != null) + message.kmsKeyVersionName = String(object.kmsKeyVersionName); return message; }; /** - * Creates a plain object from a DocumentSchema message. Also converts values to other types if specified. + * Creates a plain object from an Evaluation message. Also converts values to other types if specified. * @function toObject - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @memberof google.cloud.documentai.v1beta3.Evaluation * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema} message DocumentSchema + * @param {google.cloud.documentai.v1beta3.Evaluation} message Evaluation * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - DocumentSchema.toObject = function toObject(message, options) { + Evaluation.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) - object.entityTypes = []; + if (options.objects || options.defaults) + object.entityMetrics = {}; if (options.defaults) { - object.displayName = ""; - object.description = ""; - object.metadata = null; - } - if (message.displayName != null && message.hasOwnProperty("displayName")) - object.displayName = message.displayName; - if (message.description != null && message.hasOwnProperty("description")) - object.description = message.description; - if (message.entityTypes && message.entityTypes.length) { - object.entityTypes = []; - for (var j = 0; j < message.entityTypes.length; ++j) - object.entityTypes[j] = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.toObject(message.entityTypes[j], options); + object.name = ""; + object.createTime = null; + object.allEntitiesMetrics = null; + object.documentCounters = null; + object.kmsKeyName = ""; + object.kmsKeyVersionName = ""; } - if (message.metadata != null && message.hasOwnProperty("metadata")) - object.metadata = $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata.toObject(message.metadata, options); + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.allEntitiesMetrics != null && message.hasOwnProperty("allEntitiesMetrics")) + object.allEntitiesMetrics = $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.toObject(message.allEntitiesMetrics, options); + var keys2; + if (message.entityMetrics && (keys2 = Object.keys(message.entityMetrics)).length) { + object.entityMetrics = {}; + for (var j = 0; j < keys2.length; ++j) + object.entityMetrics[keys2[j]] = $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.toObject(message.entityMetrics[keys2[j]], options); + } + if (message.documentCounters != null && message.hasOwnProperty("documentCounters")) + object.documentCounters = $root.google.cloud.documentai.v1beta3.Evaluation.Counters.toObject(message.documentCounters, options); + if (message.kmsKeyName != null && message.hasOwnProperty("kmsKeyName")) + object.kmsKeyName = message.kmsKeyName; + if (message.kmsKeyVersionName != null && message.hasOwnProperty("kmsKeyVersionName")) + object.kmsKeyVersionName = message.kmsKeyVersionName; return object; }; /** - * Converts this DocumentSchema to JSON. + * Converts this Evaluation to JSON. * @function toJSON - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @memberof google.cloud.documentai.v1beta3.Evaluation * @instance * @returns {Object.} JSON object */ - DocumentSchema.prototype.toJSON = function toJSON() { + Evaluation.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for DocumentSchema + * Gets the default type url for Evaluation * @function getTypeUrl - * @memberof google.cloud.documentai.v1beta3.DocumentSchema + * @memberof google.cloud.documentai.v1beta3.Evaluation * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - DocumentSchema.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + Evaluation.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.cloud.documentai.v1beta3.DocumentSchema"; + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.Evaluation"; }; - DocumentSchema.EntityType = (function() { + Evaluation.Counters = (function() { /** - * Properties of an EntityType. - * @memberof google.cloud.documentai.v1beta3.DocumentSchema - * @interface IEntityType - * @property {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues|null} [enumValues] EntityType enumValues - * @property {string|null} [displayName] EntityType displayName - * @property {string|null} [name] EntityType name - * @property {Array.|null} [baseTypes] EntityType baseTypes - * @property {Array.|null} [properties] EntityType properties + * Properties of a Counters. + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @interface ICounters + * @property {number|null} [inputDocumentsCount] Counters inputDocumentsCount + * @property {number|null} [invalidDocumentsCount] Counters invalidDocumentsCount + * @property {number|null} [failedDocumentsCount] Counters failedDocumentsCount + * @property {number|null} [evaluatedDocumentsCount] Counters evaluatedDocumentsCount */ /** - * Constructs a new EntityType. - * @memberof google.cloud.documentai.v1beta3.DocumentSchema - * @classdesc Represents an EntityType. - * @implements IEntityType + * Constructs a new Counters. + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @classdesc Represents a Counters. + * @implements ICounters * @constructor - * @param {google.cloud.documentai.v1beta3.DocumentSchema.IEntityType=} [properties] Properties to set + * @param {google.cloud.documentai.v1beta3.Evaluation.ICounters=} [properties] Properties to set */ - function EntityType(properties) { - this.baseTypes = []; - this.properties = []; + function Counters(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -75938,151 +80884,117 @@ } /** - * EntityType enumValues. - * @member {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues|null|undefined} enumValues - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType - * @instance - */ - EntityType.prototype.enumValues = null; - - /** - * EntityType displayName. - * @member {string} displayName - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType - * @instance - */ - EntityType.prototype.displayName = ""; - - /** - * EntityType name. - * @member {string} name - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * Counters inputDocumentsCount. + * @member {number} inputDocumentsCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @instance */ - EntityType.prototype.name = ""; + Counters.prototype.inputDocumentsCount = 0; /** - * EntityType baseTypes. - * @member {Array.} baseTypes - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * Counters invalidDocumentsCount. + * @member {number} invalidDocumentsCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @instance */ - EntityType.prototype.baseTypes = $util.emptyArray; + Counters.prototype.invalidDocumentsCount = 0; /** - * EntityType properties. - * @member {Array.} properties - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * Counters failedDocumentsCount. + * @member {number} failedDocumentsCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @instance */ - EntityType.prototype.properties = $util.emptyArray; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; + Counters.prototype.failedDocumentsCount = 0; /** - * EntityType valueSource. - * @member {"enumValues"|undefined} valueSource - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * Counters evaluatedDocumentsCount. + * @member {number} evaluatedDocumentsCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @instance */ - Object.defineProperty(EntityType.prototype, "valueSource", { - get: $util.oneOfGetter($oneOfFields = ["enumValues"]), - set: $util.oneOfSetter($oneOfFields) - }); + Counters.prototype.evaluatedDocumentsCount = 0; /** - * Creates a new EntityType instance using the specified properties. + * Creates a new Counters instance using the specified properties. * @function create - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.IEntityType=} [properties] Properties to set - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType} EntityType instance + * @param {google.cloud.documentai.v1beta3.Evaluation.ICounters=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.Evaluation.Counters} Counters instance */ - EntityType.create = function create(properties) { - return new EntityType(properties); + Counters.create = function create(properties) { + return new Counters(properties); }; /** - * Encodes the specified EntityType message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.verify|verify} messages. + * Encodes the specified Counters message. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.Counters.verify|verify} messages. * @function encode - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.IEntityType} message EntityType message or plain object to encode + * @param {google.cloud.documentai.v1beta3.Evaluation.ICounters} message Counters message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - EntityType.encode = function encode(message, writer) { + Counters.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.name != null && Object.hasOwnProperty.call(message, "name")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.baseTypes != null && message.baseTypes.length) - for (var i = 0; i < message.baseTypes.length; ++i) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.baseTypes[i]); - if (message.properties != null && message.properties.length) - for (var i = 0; i < message.properties.length; ++i) - $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.encode(message.properties[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); - if (message.displayName != null && Object.hasOwnProperty.call(message, "displayName")) - writer.uint32(/* id 13, wireType 2 =*/106).string(message.displayName); - if (message.enumValues != null && Object.hasOwnProperty.call(message, "enumValues")) - $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.encode(message.enumValues, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.inputDocumentsCount != null && Object.hasOwnProperty.call(message, "inputDocumentsCount")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.inputDocumentsCount); + if (message.invalidDocumentsCount != null && Object.hasOwnProperty.call(message, "invalidDocumentsCount")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.invalidDocumentsCount); + if (message.failedDocumentsCount != null && Object.hasOwnProperty.call(message, "failedDocumentsCount")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.failedDocumentsCount); + if (message.evaluatedDocumentsCount != null && Object.hasOwnProperty.call(message, "evaluatedDocumentsCount")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.evaluatedDocumentsCount); return writer; }; /** - * Encodes the specified EntityType message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.verify|verify} messages. + * Encodes the specified Counters message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.Counters.verify|verify} messages. * @function encodeDelimited - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.IEntityType} message EntityType message or plain object to encode + * @param {google.cloud.documentai.v1beta3.Evaluation.ICounters} message Counters message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - EntityType.encodeDelimited = function encodeDelimited(message, writer) { + Counters.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes an EntityType message from the specified reader or buffer. + * Decodes a Counters message from the specified reader or buffer. * @function decode - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType} EntityType + * @returns {google.cloud.documentai.v1beta3.Evaluation.Counters} Counters * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - EntityType.decode = function decode(reader, length) { + Counters.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Evaluation.Counters(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { - case 14: { - message.enumValues = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.decode(reader, reader.uint32()); - break; - } - case 13: { - message.displayName = reader.string(); - break; - } case 1: { - message.name = reader.string(); + message.inputDocumentsCount = reader.int32(); break; } case 2: { - if (!(message.baseTypes && message.baseTypes.length)) - message.baseTypes = []; - message.baseTypes.push(reader.string()); + message.invalidDocumentsCount = reader.int32(); break; } - case 6: { - if (!(message.properties && message.properties.length)) - message.properties = []; - message.properties.push($root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.decode(reader, reader.uint32())); + case 3: { + message.failedDocumentsCount = reader.int32(); + break; + } + case 4: { + message.evaluatedDocumentsCount = reader.int32(); break; } default: @@ -76094,723 +81006,821 @@ }; /** - * Decodes an EntityType message from the specified reader or buffer, length delimited. + * Decodes a Counters message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType} EntityType + * @returns {google.cloud.documentai.v1beta3.Evaluation.Counters} Counters * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - EntityType.decodeDelimited = function decodeDelimited(reader) { + Counters.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies an EntityType message. + * Verifies a Counters message. * @function verify - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - EntityType.verify = function verify(message) { + Counters.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - var properties = {}; - if (message.enumValues != null && message.hasOwnProperty("enumValues")) { - properties.valueSource = 1; - { - var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.verify(message.enumValues); - if (error) - return "enumValues." + error; - } - } - if (message.displayName != null && message.hasOwnProperty("displayName")) - if (!$util.isString(message.displayName)) - return "displayName: string expected"; - if (message.name != null && message.hasOwnProperty("name")) - if (!$util.isString(message.name)) - return "name: string expected"; - if (message.baseTypes != null && message.hasOwnProperty("baseTypes")) { - if (!Array.isArray(message.baseTypes)) - return "baseTypes: array expected"; - for (var i = 0; i < message.baseTypes.length; ++i) - if (!$util.isString(message.baseTypes[i])) - return "baseTypes: string[] expected"; - } - if (message.properties != null && message.hasOwnProperty("properties")) { - if (!Array.isArray(message.properties)) - return "properties: array expected"; - for (var i = 0; i < message.properties.length; ++i) { - var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.verify(message.properties[i]); - if (error) - return "properties." + error; - } - } + if (message.inputDocumentsCount != null && message.hasOwnProperty("inputDocumentsCount")) + if (!$util.isInteger(message.inputDocumentsCount)) + return "inputDocumentsCount: integer expected"; + if (message.invalidDocumentsCount != null && message.hasOwnProperty("invalidDocumentsCount")) + if (!$util.isInteger(message.invalidDocumentsCount)) + return "invalidDocumentsCount: integer expected"; + if (message.failedDocumentsCount != null && message.hasOwnProperty("failedDocumentsCount")) + if (!$util.isInteger(message.failedDocumentsCount)) + return "failedDocumentsCount: integer expected"; + if (message.evaluatedDocumentsCount != null && message.hasOwnProperty("evaluatedDocumentsCount")) + if (!$util.isInteger(message.evaluatedDocumentsCount)) + return "evaluatedDocumentsCount: integer expected"; return null; }; /** - * Creates an EntityType message from a plain object. Also converts values to their respective internal types. + * Creates a Counters message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @static * @param {Object.} object Plain object - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType} EntityType + * @returns {google.cloud.documentai.v1beta3.Evaluation.Counters} Counters */ - EntityType.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType) - return object; - var message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType(); - if (object.enumValues != null) { - if (typeof object.enumValues !== "object") - throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.EntityType.enumValues: object expected"); - message.enumValues = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.fromObject(object.enumValues); - } - if (object.displayName != null) - message.displayName = String(object.displayName); - if (object.name != null) - message.name = String(object.name); - if (object.baseTypes) { - if (!Array.isArray(object.baseTypes)) - throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.EntityType.baseTypes: array expected"); - message.baseTypes = []; - for (var i = 0; i < object.baseTypes.length; ++i) - message.baseTypes[i] = String(object.baseTypes[i]); - } - if (object.properties) { - if (!Array.isArray(object.properties)) - throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.EntityType.properties: array expected"); - message.properties = []; - for (var i = 0; i < object.properties.length; ++i) { - if (typeof object.properties[i] !== "object") - throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.EntityType.properties: object expected"); - message.properties[i] = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.fromObject(object.properties[i]); - } - } + Counters.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.Evaluation.Counters) + return object; + var message = new $root.google.cloud.documentai.v1beta3.Evaluation.Counters(); + if (object.inputDocumentsCount != null) + message.inputDocumentsCount = object.inputDocumentsCount | 0; + if (object.invalidDocumentsCount != null) + message.invalidDocumentsCount = object.invalidDocumentsCount | 0; + if (object.failedDocumentsCount != null) + message.failedDocumentsCount = object.failedDocumentsCount | 0; + if (object.evaluatedDocumentsCount != null) + message.evaluatedDocumentsCount = object.evaluatedDocumentsCount | 0; return message; }; /** - * Creates a plain object from an EntityType message. Also converts values to other types if specified. + * Creates a plain object from a Counters message. Also converts values to other types if specified. * @function toObject - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType} message EntityType + * @param {google.cloud.documentai.v1beta3.Evaluation.Counters} message Counters * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - EntityType.toObject = function toObject(message, options) { + Counters.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) { - object.baseTypes = []; - object.properties = []; - } if (options.defaults) { - object.name = ""; - object.displayName = ""; - } - if (message.name != null && message.hasOwnProperty("name")) - object.name = message.name; - if (message.baseTypes && message.baseTypes.length) { - object.baseTypes = []; - for (var j = 0; j < message.baseTypes.length; ++j) - object.baseTypes[j] = message.baseTypes[j]; - } - if (message.properties && message.properties.length) { - object.properties = []; - for (var j = 0; j < message.properties.length; ++j) - object.properties[j] = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.toObject(message.properties[j], options); - } - if (message.displayName != null && message.hasOwnProperty("displayName")) - object.displayName = message.displayName; - if (message.enumValues != null && message.hasOwnProperty("enumValues")) { - object.enumValues = $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.toObject(message.enumValues, options); - if (options.oneofs) - object.valueSource = "enumValues"; - } + object.inputDocumentsCount = 0; + object.invalidDocumentsCount = 0; + object.failedDocumentsCount = 0; + object.evaluatedDocumentsCount = 0; + } + if (message.inputDocumentsCount != null && message.hasOwnProperty("inputDocumentsCount")) + object.inputDocumentsCount = message.inputDocumentsCount; + if (message.invalidDocumentsCount != null && message.hasOwnProperty("invalidDocumentsCount")) + object.invalidDocumentsCount = message.invalidDocumentsCount; + if (message.failedDocumentsCount != null && message.hasOwnProperty("failedDocumentsCount")) + object.failedDocumentsCount = message.failedDocumentsCount; + if (message.evaluatedDocumentsCount != null && message.hasOwnProperty("evaluatedDocumentsCount")) + object.evaluatedDocumentsCount = message.evaluatedDocumentsCount; return object; }; /** - * Converts this EntityType to JSON. + * Converts this Counters to JSON. * @function toJSON - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @instance * @returns {Object.} JSON object */ - EntityType.prototype.toJSON = function toJSON() { + Counters.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for EntityType + * Gets the default type url for Counters * @function getTypeUrl - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType + * @memberof google.cloud.documentai.v1beta3.Evaluation.Counters * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - EntityType.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + Counters.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.cloud.documentai.v1beta3.DocumentSchema.EntityType"; + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.Evaluation.Counters"; }; - EntityType.EnumValues = (function() { + return Counters; + })(); - /** - * Properties of an EnumValues. - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType - * @interface IEnumValues - * @property {Array.|null} [values] EnumValues values - */ + Evaluation.Metrics = (function() { - /** - * Constructs a new EnumValues. - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType - * @classdesc Represents an EnumValues. - * @implements IEnumValues - * @constructor - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues=} [properties] Properties to set - */ - function EnumValues(properties) { - this.values = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + /** + * Properties of a Metrics. + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @interface IMetrics + * @property {number|null} [precision] Metrics precision + * @property {number|null} [recall] Metrics recall + * @property {number|null} [f1Score] Metrics f1Score + * @property {number|null} [predictedOccurrencesCount] Metrics predictedOccurrencesCount + * @property {number|null} [groundTruthOccurrencesCount] Metrics groundTruthOccurrencesCount + * @property {number|null} [predictedDocumentCount] Metrics predictedDocumentCount + * @property {number|null} [groundTruthDocumentCount] Metrics groundTruthDocumentCount + * @property {number|null} [truePositivesCount] Metrics truePositivesCount + * @property {number|null} [falsePositivesCount] Metrics falsePositivesCount + * @property {number|null} [falseNegativesCount] Metrics falseNegativesCount + * @property {number|null} [totalDocumentsCount] Metrics totalDocumentsCount + */ - /** - * EnumValues values. - * @member {Array.} values - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @instance - */ - EnumValues.prototype.values = $util.emptyArray; + /** + * Constructs a new Metrics. + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @classdesc Represents a Metrics. + * @implements IMetrics + * @constructor + * @param {google.cloud.documentai.v1beta3.Evaluation.IMetrics=} [properties] Properties to set + */ + function Metrics(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } - /** - * Creates a new EnumValues instance using the specified properties. - * @function create - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues=} [properties] Properties to set - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues} EnumValues instance - */ - EnumValues.create = function create(properties) { - return new EnumValues(properties); - }; + /** + * Metrics precision. + * @member {number} precision + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.precision = 0; - /** - * Encodes the specified EnumValues message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.verify|verify} messages. - * @function encode - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues} message EnumValues message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EnumValues.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.values != null && message.values.length) - for (var i = 0; i < message.values.length; ++i) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.values[i]); - return writer; - }; + /** + * Metrics recall. + * @member {number} recall + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.recall = 0; - /** - * Encodes the specified EnumValues message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.verify|verify} messages. - * @function encodeDelimited - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IEnumValues} message EnumValues message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - EnumValues.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + /** + * Metrics f1Score. + * @member {number} f1Score + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.f1Score = 0; - /** - * Decodes an EnumValues message from the specified reader or buffer. - * @function decode - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues} EnumValues - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EnumValues.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: { - if (!(message.values && message.values.length)) - message.values = []; - message.values.push(reader.string()); - break; - } - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + /** + * Metrics predictedOccurrencesCount. + * @member {number} predictedOccurrencesCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.predictedOccurrencesCount = 0; - /** - * Decodes an EnumValues message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues} EnumValues - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - EnumValues.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + /** + * Metrics groundTruthOccurrencesCount. + * @member {number} groundTruthOccurrencesCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.groundTruthOccurrencesCount = 0; - /** - * Verifies an EnumValues message. - * @function verify - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - EnumValues.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.values != null && message.hasOwnProperty("values")) { - if (!Array.isArray(message.values)) - return "values: array expected"; - for (var i = 0; i < message.values.length; ++i) - if (!$util.isString(message.values[i])) - return "values: string[] expected"; - } - return null; - }; + /** + * Metrics predictedDocumentCount. + * @member {number} predictedDocumentCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.predictedDocumentCount = 0; - /** - * Creates an EnumValues message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @static - * @param {Object.} object Plain object - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues} EnumValues - */ - EnumValues.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues) - return object; - var message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues(); - if (object.values) { - if (!Array.isArray(object.values)) - throw TypeError(".google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues.values: array expected"); - message.values = []; - for (var i = 0; i < object.values.length; ++i) - message.values[i] = String(object.values[i]); - } - return message; - }; + /** + * Metrics groundTruthDocumentCount. + * @member {number} groundTruthDocumentCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.groundTruthDocumentCount = 0; + + /** + * Metrics truePositivesCount. + * @member {number} truePositivesCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.truePositivesCount = 0; + + /** + * Metrics falsePositivesCount. + * @member {number} falsePositivesCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.falsePositivesCount = 0; + + /** + * Metrics falseNegativesCount. + * @member {number} falseNegativesCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.falseNegativesCount = 0; + + /** + * Metrics totalDocumentsCount. + * @member {number} totalDocumentsCount + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + */ + Metrics.prototype.totalDocumentsCount = 0; + + /** + * Creates a new Metrics instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @static + * @param {google.cloud.documentai.v1beta3.Evaluation.IMetrics=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.Evaluation.Metrics} Metrics instance + */ + Metrics.create = function create(properties) { + return new Metrics(properties); + }; + + /** + * Encodes the specified Metrics message. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.Metrics.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @static + * @param {google.cloud.documentai.v1beta3.Evaluation.IMetrics} message Metrics message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Metrics.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.precision != null && Object.hasOwnProperty.call(message, "precision")) + writer.uint32(/* id 1, wireType 5 =*/13).float(message.precision); + if (message.recall != null && Object.hasOwnProperty.call(message, "recall")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.recall); + if (message.f1Score != null && Object.hasOwnProperty.call(message, "f1Score")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.f1Score); + if (message.predictedOccurrencesCount != null && Object.hasOwnProperty.call(message, "predictedOccurrencesCount")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.predictedOccurrencesCount); + if (message.groundTruthOccurrencesCount != null && Object.hasOwnProperty.call(message, "groundTruthOccurrencesCount")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.groundTruthOccurrencesCount); + if (message.truePositivesCount != null && Object.hasOwnProperty.call(message, "truePositivesCount")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.truePositivesCount); + if (message.falsePositivesCount != null && Object.hasOwnProperty.call(message, "falsePositivesCount")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.falsePositivesCount); + if (message.falseNegativesCount != null && Object.hasOwnProperty.call(message, "falseNegativesCount")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.falseNegativesCount); + if (message.totalDocumentsCount != null && Object.hasOwnProperty.call(message, "totalDocumentsCount")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.totalDocumentsCount); + if (message.predictedDocumentCount != null && Object.hasOwnProperty.call(message, "predictedDocumentCount")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.predictedDocumentCount); + if (message.groundTruthDocumentCount != null && Object.hasOwnProperty.call(message, "groundTruthDocumentCount")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.groundTruthDocumentCount); + return writer; + }; - /** - * Creates a plain object from an EnumValues message. Also converts values to other types if specified. - * @function toObject - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues} message EnumValues - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - EnumValues.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) - object.values = []; - if (message.values && message.values.length) { - object.values = []; - for (var j = 0; j < message.values.length; ++j) - object.values[j] = message.values[j]; + /** + * Encodes the specified Metrics message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.Metrics.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @static + * @param {google.cloud.documentai.v1beta3.Evaluation.IMetrics} message Metrics message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Metrics.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Metrics message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.Evaluation.Metrics} Metrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Metrics.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Evaluation.Metrics(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.precision = reader.float(); + break; + } + case 2: { + message.recall = reader.float(); + break; + } + case 3: { + message.f1Score = reader.float(); + break; + } + case 4: { + message.predictedOccurrencesCount = reader.int32(); + break; + } + case 5: { + message.groundTruthOccurrencesCount = reader.int32(); + break; + } + case 10: { + message.predictedDocumentCount = reader.int32(); + break; + } + case 11: { + message.groundTruthDocumentCount = reader.int32(); + break; + } + case 6: { + message.truePositivesCount = reader.int32(); + break; + } + case 7: { + message.falsePositivesCount = reader.int32(); + break; + } + case 8: { + message.falseNegativesCount = reader.int32(); + break; + } + case 9: { + message.totalDocumentsCount = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; } - return object; - }; + } + return message; + }; - /** - * Converts this EnumValues to JSON. - * @function toJSON - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @instance - * @returns {Object.} JSON object - */ - EnumValues.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + /** + * Decodes a Metrics message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.Evaluation.Metrics} Metrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Metrics.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; - /** - * Gets the default type url for EnumValues - * @function getTypeUrl - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues - * @static - * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns {string} The default type url - */ - EnumValues.getTypeUrl = function getTypeUrl(typeUrlPrefix) { - if (typeUrlPrefix === undefined) { - typeUrlPrefix = "type.googleapis.com"; - } - return typeUrlPrefix + "/google.cloud.documentai.v1beta3.DocumentSchema.EntityType.EnumValues"; - }; + /** + * Verifies a Metrics message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Metrics.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.precision != null && message.hasOwnProperty("precision")) + if (typeof message.precision !== "number") + return "precision: number expected"; + if (message.recall != null && message.hasOwnProperty("recall")) + if (typeof message.recall !== "number") + return "recall: number expected"; + if (message.f1Score != null && message.hasOwnProperty("f1Score")) + if (typeof message.f1Score !== "number") + return "f1Score: number expected"; + if (message.predictedOccurrencesCount != null && message.hasOwnProperty("predictedOccurrencesCount")) + if (!$util.isInteger(message.predictedOccurrencesCount)) + return "predictedOccurrencesCount: integer expected"; + if (message.groundTruthOccurrencesCount != null && message.hasOwnProperty("groundTruthOccurrencesCount")) + if (!$util.isInteger(message.groundTruthOccurrencesCount)) + return "groundTruthOccurrencesCount: integer expected"; + if (message.predictedDocumentCount != null && message.hasOwnProperty("predictedDocumentCount")) + if (!$util.isInteger(message.predictedDocumentCount)) + return "predictedDocumentCount: integer expected"; + if (message.groundTruthDocumentCount != null && message.hasOwnProperty("groundTruthDocumentCount")) + if (!$util.isInteger(message.groundTruthDocumentCount)) + return "groundTruthDocumentCount: integer expected"; + if (message.truePositivesCount != null && message.hasOwnProperty("truePositivesCount")) + if (!$util.isInteger(message.truePositivesCount)) + return "truePositivesCount: integer expected"; + if (message.falsePositivesCount != null && message.hasOwnProperty("falsePositivesCount")) + if (!$util.isInteger(message.falsePositivesCount)) + return "falsePositivesCount: integer expected"; + if (message.falseNegativesCount != null && message.hasOwnProperty("falseNegativesCount")) + if (!$util.isInteger(message.falseNegativesCount)) + return "falseNegativesCount: integer expected"; + if (message.totalDocumentsCount != null && message.hasOwnProperty("totalDocumentsCount")) + if (!$util.isInteger(message.totalDocumentsCount)) + return "totalDocumentsCount: integer expected"; + return null; + }; - return EnumValues; - })(); + /** + * Creates a Metrics message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.Evaluation.Metrics} Metrics + */ + Metrics.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.Evaluation.Metrics) + return object; + var message = new $root.google.cloud.documentai.v1beta3.Evaluation.Metrics(); + if (object.precision != null) + message.precision = Number(object.precision); + if (object.recall != null) + message.recall = Number(object.recall); + if (object.f1Score != null) + message.f1Score = Number(object.f1Score); + if (object.predictedOccurrencesCount != null) + message.predictedOccurrencesCount = object.predictedOccurrencesCount | 0; + if (object.groundTruthOccurrencesCount != null) + message.groundTruthOccurrencesCount = object.groundTruthOccurrencesCount | 0; + if (object.predictedDocumentCount != null) + message.predictedDocumentCount = object.predictedDocumentCount | 0; + if (object.groundTruthDocumentCount != null) + message.groundTruthDocumentCount = object.groundTruthDocumentCount | 0; + if (object.truePositivesCount != null) + message.truePositivesCount = object.truePositivesCount | 0; + if (object.falsePositivesCount != null) + message.falsePositivesCount = object.falsePositivesCount | 0; + if (object.falseNegativesCount != null) + message.falseNegativesCount = object.falseNegativesCount | 0; + if (object.totalDocumentsCount != null) + message.totalDocumentsCount = object.totalDocumentsCount | 0; + return message; + }; - EntityType.Property = (function() { + /** + * Creates a plain object from a Metrics message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @static + * @param {google.cloud.documentai.v1beta3.Evaluation.Metrics} message Metrics + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Metrics.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.precision = 0; + object.recall = 0; + object.f1Score = 0; + object.predictedOccurrencesCount = 0; + object.groundTruthOccurrencesCount = 0; + object.truePositivesCount = 0; + object.falsePositivesCount = 0; + object.falseNegativesCount = 0; + object.totalDocumentsCount = 0; + object.predictedDocumentCount = 0; + object.groundTruthDocumentCount = 0; + } + if (message.precision != null && message.hasOwnProperty("precision")) + object.precision = options.json && !isFinite(message.precision) ? String(message.precision) : message.precision; + if (message.recall != null && message.hasOwnProperty("recall")) + object.recall = options.json && !isFinite(message.recall) ? String(message.recall) : message.recall; + if (message.f1Score != null && message.hasOwnProperty("f1Score")) + object.f1Score = options.json && !isFinite(message.f1Score) ? String(message.f1Score) : message.f1Score; + if (message.predictedOccurrencesCount != null && message.hasOwnProperty("predictedOccurrencesCount")) + object.predictedOccurrencesCount = message.predictedOccurrencesCount; + if (message.groundTruthOccurrencesCount != null && message.hasOwnProperty("groundTruthOccurrencesCount")) + object.groundTruthOccurrencesCount = message.groundTruthOccurrencesCount; + if (message.truePositivesCount != null && message.hasOwnProperty("truePositivesCount")) + object.truePositivesCount = message.truePositivesCount; + if (message.falsePositivesCount != null && message.hasOwnProperty("falsePositivesCount")) + object.falsePositivesCount = message.falsePositivesCount; + if (message.falseNegativesCount != null && message.hasOwnProperty("falseNegativesCount")) + object.falseNegativesCount = message.falseNegativesCount; + if (message.totalDocumentsCount != null && message.hasOwnProperty("totalDocumentsCount")) + object.totalDocumentsCount = message.totalDocumentsCount; + if (message.predictedDocumentCount != null && message.hasOwnProperty("predictedDocumentCount")) + object.predictedDocumentCount = message.predictedDocumentCount; + if (message.groundTruthDocumentCount != null && message.hasOwnProperty("groundTruthDocumentCount")) + object.groundTruthDocumentCount = message.groundTruthDocumentCount; + return object; + }; - /** - * Properties of a Property. - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType - * @interface IProperty - * @property {string|null} [name] Property name - * @property {string|null} [valueType] Property valueType - * @property {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType|null} [occurrenceType] Property occurrenceType - */ + /** + * Converts this Metrics to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @instance + * @returns {Object.} JSON object + */ + Metrics.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; - /** - * Constructs a new Property. - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType - * @classdesc Represents a Property. - * @implements IProperty - * @constructor - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty=} [properties] Properties to set - */ - function Property(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; + /** + * Gets the default type url for Metrics + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.Evaluation.Metrics + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Metrics.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.Evaluation.Metrics"; + }; - /** - * Property name. - * @member {string} name - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @instance - */ - Property.prototype.name = ""; + return Metrics; + })(); - /** - * Property valueType. - * @member {string} valueType - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @instance - */ - Property.prototype.valueType = ""; + Evaluation.ConfidenceLevelMetrics = (function() { - /** - * Property occurrenceType. - * @member {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType} occurrenceType - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @instance - */ - Property.prototype.occurrenceType = 0; + /** + * Properties of a ConfidenceLevelMetrics. + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @interface IConfidenceLevelMetrics + * @property {number|null} [confidenceLevel] ConfidenceLevelMetrics confidenceLevel + * @property {google.cloud.documentai.v1beta3.Evaluation.IMetrics|null} [metrics] ConfidenceLevelMetrics metrics + */ - /** - * Creates a new Property instance using the specified properties. - * @function create - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty=} [properties] Properties to set - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property} Property instance - */ - Property.create = function create(properties) { - return new Property(properties); - }; + /** + * Constructs a new ConfidenceLevelMetrics. + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @classdesc Represents a ConfidenceLevelMetrics. + * @implements IConfidenceLevelMetrics + * @constructor + * @param {google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics=} [properties] Properties to set + */ + function ConfidenceLevelMetrics(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } - /** - * Encodes the specified Property message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.verify|verify} messages. - * @function encode - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty} message Property message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Property.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.name != null && Object.hasOwnProperty.call(message, "name")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); - if (message.valueType != null && Object.hasOwnProperty.call(message, "valueType")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.valueType); - if (message.occurrenceType != null && Object.hasOwnProperty.call(message, "occurrenceType")) - writer.uint32(/* id 3, wireType 0 =*/24).int32(message.occurrenceType); - return writer; - }; + /** + * ConfidenceLevelMetrics confidenceLevel. + * @member {number} confidenceLevel + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @instance + */ + ConfidenceLevelMetrics.prototype.confidenceLevel = 0; - /** - * Encodes the specified Property message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.verify|verify} messages. - * @function encodeDelimited - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.IProperty} message Property message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Property.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + /** + * ConfidenceLevelMetrics metrics. + * @member {google.cloud.documentai.v1beta3.Evaluation.IMetrics|null|undefined} metrics + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @instance + */ + ConfidenceLevelMetrics.prototype.metrics = null; - /** - * Decodes a Property message from the specified reader or buffer. - * @function decode - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property} Property - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Property.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: { - message.name = reader.string(); - break; - } - case 2: { - message.valueType = reader.string(); - break; - } - case 3: { - message.occurrenceType = reader.int32(); - break; - } - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + /** + * Creates a new ConfidenceLevelMetrics instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @static + * @param {google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics} ConfidenceLevelMetrics instance + */ + ConfidenceLevelMetrics.create = function create(properties) { + return new ConfidenceLevelMetrics(properties); + }; - /** - * Decodes a Property message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property} Property - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Property.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + /** + * Encodes the specified ConfidenceLevelMetrics message. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @static + * @param {google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics} message ConfidenceLevelMetrics message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ConfidenceLevelMetrics.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.confidenceLevel != null && Object.hasOwnProperty.call(message, "confidenceLevel")) + writer.uint32(/* id 1, wireType 5 =*/13).float(message.confidenceLevel); + if (message.metrics != null && Object.hasOwnProperty.call(message, "metrics")) + $root.google.cloud.documentai.v1beta3.Evaluation.Metrics.encode(message.metrics, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; - /** - * Verifies a Property message. - * @function verify - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Property.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.name != null && message.hasOwnProperty("name")) - if (!$util.isString(message.name)) - return "name: string expected"; - if (message.valueType != null && message.hasOwnProperty("valueType")) - if (!$util.isString(message.valueType)) - return "valueType: string expected"; - if (message.occurrenceType != null && message.hasOwnProperty("occurrenceType")) - switch (message.occurrenceType) { - default: - return "occurrenceType: enum value expected"; - case 0: - case 1: - case 2: - case 3: - case 4: + /** + * Encodes the specified ConfidenceLevelMetrics message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @static + * @param {google.cloud.documentai.v1beta3.Evaluation.IConfidenceLevelMetrics} message ConfidenceLevelMetrics message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ConfidenceLevelMetrics.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ConfidenceLevelMetrics message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics} ConfidenceLevelMetrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ConfidenceLevelMetrics.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.confidenceLevel = reader.float(); break; } - return null; - }; - - /** - * Creates a Property message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @static - * @param {Object.} object Plain object - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property} Property - */ - Property.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property) - return object; - var message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property(); - if (object.name != null) - message.name = String(object.name); - if (object.valueType != null) - message.valueType = String(object.valueType); - switch (object.occurrenceType) { - default: - if (typeof object.occurrenceType === "number") { - message.occurrenceType = object.occurrenceType; + case 2: { + message.metrics = $root.google.cloud.documentai.v1beta3.Evaluation.Metrics.decode(reader, reader.uint32()); break; } + default: + reader.skipType(tag & 7); break; - case "OCCURRENCE_TYPE_UNSPECIFIED": - case 0: - message.occurrenceType = 0; - break; - case "OPTIONAL_ONCE": - case 1: - message.occurrenceType = 1; - break; - case "OPTIONAL_MULTIPLE": - case 2: - message.occurrenceType = 2; - break; - case "REQUIRED_ONCE": - case 3: - message.occurrenceType = 3; - break; - case "REQUIRED_MULTIPLE": - case 4: - message.occurrenceType = 4; - break; - } - return message; - }; - - /** - * Creates a plain object from a Property message. Also converts values to other types if specified. - * @function toObject - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property} message Property - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Property.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.name = ""; - object.valueType = ""; - object.occurrenceType = options.enums === String ? "OCCURRENCE_TYPE_UNSPECIFIED" : 0; } - if (message.name != null && message.hasOwnProperty("name")) - object.name = message.name; - if (message.valueType != null && message.hasOwnProperty("valueType")) - object.valueType = message.valueType; - if (message.occurrenceType != null && message.hasOwnProperty("occurrenceType")) - object.occurrenceType = options.enums === String ? $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType[message.occurrenceType] === undefined ? message.occurrenceType : $root.google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType[message.occurrenceType] : message.occurrenceType; - return object; - }; + } + return message; + }; - /** - * Converts this Property to JSON. - * @function toJSON - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @instance - * @returns {Object.} JSON object - */ - Property.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + /** + * Decodes a ConfidenceLevelMetrics message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics} ConfidenceLevelMetrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ConfidenceLevelMetrics.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; - /** - * Gets the default type url for Property - * @function getTypeUrl - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property - * @static - * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns {string} The default type url - */ - Property.getTypeUrl = function getTypeUrl(typeUrlPrefix) { - if (typeUrlPrefix === undefined) { - typeUrlPrefix = "type.googleapis.com"; - } - return typeUrlPrefix + "/google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property"; - }; + /** + * Verifies a ConfidenceLevelMetrics message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ConfidenceLevelMetrics.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.confidenceLevel != null && message.hasOwnProperty("confidenceLevel")) + if (typeof message.confidenceLevel !== "number") + return "confidenceLevel: number expected"; + if (message.metrics != null && message.hasOwnProperty("metrics")) { + var error = $root.google.cloud.documentai.v1beta3.Evaluation.Metrics.verify(message.metrics); + if (error) + return "metrics." + error; + } + return null; + }; - /** - * OccurrenceType enum. - * @name google.cloud.documentai.v1beta3.DocumentSchema.EntityType.Property.OccurrenceType - * @enum {number} - * @property {number} OCCURRENCE_TYPE_UNSPECIFIED=0 OCCURRENCE_TYPE_UNSPECIFIED value - * @property {number} OPTIONAL_ONCE=1 OPTIONAL_ONCE value - * @property {number} OPTIONAL_MULTIPLE=2 OPTIONAL_MULTIPLE value - * @property {number} REQUIRED_ONCE=3 REQUIRED_ONCE value - * @property {number} REQUIRED_MULTIPLE=4 REQUIRED_MULTIPLE value - */ - Property.OccurrenceType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "OCCURRENCE_TYPE_UNSPECIFIED"] = 0; - values[valuesById[1] = "OPTIONAL_ONCE"] = 1; - values[valuesById[2] = "OPTIONAL_MULTIPLE"] = 2; - values[valuesById[3] = "REQUIRED_ONCE"] = 3; - values[valuesById[4] = "REQUIRED_MULTIPLE"] = 4; - return values; - })(); + /** + * Creates a ConfidenceLevelMetrics message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics} ConfidenceLevelMetrics + */ + ConfidenceLevelMetrics.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics) + return object; + var message = new $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics(); + if (object.confidenceLevel != null) + message.confidenceLevel = Number(object.confidenceLevel); + if (object.metrics != null) { + if (typeof object.metrics !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.metrics: object expected"); + message.metrics = $root.google.cloud.documentai.v1beta3.Evaluation.Metrics.fromObject(object.metrics); + } + return message; + }; - return Property; - })(); + /** + * Creates a plain object from a ConfidenceLevelMetrics message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @static + * @param {google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics} message ConfidenceLevelMetrics + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ConfidenceLevelMetrics.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.confidenceLevel = 0; + object.metrics = null; + } + if (message.confidenceLevel != null && message.hasOwnProperty("confidenceLevel")) + object.confidenceLevel = options.json && !isFinite(message.confidenceLevel) ? String(message.confidenceLevel) : message.confidenceLevel; + if (message.metrics != null && message.hasOwnProperty("metrics")) + object.metrics = $root.google.cloud.documentai.v1beta3.Evaluation.Metrics.toObject(message.metrics, options); + return object; + }; - return EntityType; + /** + * Converts this ConfidenceLevelMetrics to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @instance + * @returns {Object.} JSON object + */ + ConfidenceLevelMetrics.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ConfidenceLevelMetrics + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ConfidenceLevelMetrics.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics"; + }; + + return ConfidenceLevelMetrics; })(); - DocumentSchema.Metadata = (function() { + Evaluation.MultiConfidenceMetrics = (function() { /** - * Properties of a Metadata. - * @memberof google.cloud.documentai.v1beta3.DocumentSchema - * @interface IMetadata - * @property {boolean|null} [documentSplitter] Metadata documentSplitter - * @property {boolean|null} [documentAllowMultipleLabels] Metadata documentAllowMultipleLabels - * @property {boolean|null} [prefixedNamingOnProperties] Metadata prefixedNamingOnProperties - * @property {boolean|null} [skipNamingValidation] Metadata skipNamingValidation + * Properties of a MultiConfidenceMetrics. + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @interface IMultiConfidenceMetrics + * @property {Array.|null} [confidenceLevelMetrics] MultiConfidenceMetrics confidenceLevelMetrics + * @property {Array.|null} [confidenceLevelMetricsExact] MultiConfidenceMetrics confidenceLevelMetricsExact + * @property {number|null} [auprc] MultiConfidenceMetrics auprc + * @property {number|null} [estimatedCalibrationError] MultiConfidenceMetrics estimatedCalibrationError + * @property {number|null} [auprcExact] MultiConfidenceMetrics auprcExact + * @property {number|null} [estimatedCalibrationErrorExact] MultiConfidenceMetrics estimatedCalibrationErrorExact + * @property {google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.MetricsType|null} [metricsType] MultiConfidenceMetrics metricsType */ /** - * Constructs a new Metadata. - * @memberof google.cloud.documentai.v1beta3.DocumentSchema - * @classdesc Represents a Metadata. - * @implements IMetadata + * Constructs a new MultiConfidenceMetrics. + * @memberof google.cloud.documentai.v1beta3.Evaluation + * @classdesc Represents a MultiConfidenceMetrics. + * @implements IMultiConfidenceMetrics * @constructor - * @param {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata=} [properties] Properties to set + * @param {google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics=} [properties] Properties to set */ - function Metadata(properties) { + function MultiConfidenceMetrics(properties) { + this.confidenceLevelMetrics = []; + this.confidenceLevelMetricsExact = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -76818,117 +81828,165 @@ } /** - * Metadata documentSplitter. - * @member {boolean} documentSplitter - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * MultiConfidenceMetrics confidenceLevelMetrics. + * @member {Array.} confidenceLevelMetrics + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @instance */ - Metadata.prototype.documentSplitter = false; + MultiConfidenceMetrics.prototype.confidenceLevelMetrics = $util.emptyArray; /** - * Metadata documentAllowMultipleLabels. - * @member {boolean} documentAllowMultipleLabels - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * MultiConfidenceMetrics confidenceLevelMetricsExact. + * @member {Array.} confidenceLevelMetricsExact + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @instance */ - Metadata.prototype.documentAllowMultipleLabels = false; + MultiConfidenceMetrics.prototype.confidenceLevelMetricsExact = $util.emptyArray; /** - * Metadata prefixedNamingOnProperties. - * @member {boolean} prefixedNamingOnProperties - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * MultiConfidenceMetrics auprc. + * @member {number} auprc + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @instance */ - Metadata.prototype.prefixedNamingOnProperties = false; + MultiConfidenceMetrics.prototype.auprc = 0; /** - * Metadata skipNamingValidation. - * @member {boolean} skipNamingValidation - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * MultiConfidenceMetrics estimatedCalibrationError. + * @member {number} estimatedCalibrationError + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @instance */ - Metadata.prototype.skipNamingValidation = false; + MultiConfidenceMetrics.prototype.estimatedCalibrationError = 0; /** - * Creates a new Metadata instance using the specified properties. + * MultiConfidenceMetrics auprcExact. + * @member {number} auprcExact + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics + * @instance + */ + MultiConfidenceMetrics.prototype.auprcExact = 0; + + /** + * MultiConfidenceMetrics estimatedCalibrationErrorExact. + * @member {number} estimatedCalibrationErrorExact + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics + * @instance + */ + MultiConfidenceMetrics.prototype.estimatedCalibrationErrorExact = 0; + + /** + * MultiConfidenceMetrics metricsType. + * @member {google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.MetricsType} metricsType + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics + * @instance + */ + MultiConfidenceMetrics.prototype.metricsType = 0; + + /** + * Creates a new MultiConfidenceMetrics instance using the specified properties. * @function create - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata=} [properties] Properties to set - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.Metadata} Metadata instance + * @param {google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics} MultiConfidenceMetrics instance */ - Metadata.create = function create(properties) { - return new Metadata(properties); + MultiConfidenceMetrics.create = function create(properties) { + return new MultiConfidenceMetrics(properties); }; /** - * Encodes the specified Metadata message. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.Metadata.verify|verify} messages. + * Encodes the specified MultiConfidenceMetrics message. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.verify|verify} messages. * @function encode - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata} message Metadata message or plain object to encode + * @param {google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics} message MultiConfidenceMetrics message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - Metadata.encode = function encode(message, writer) { + MultiConfidenceMetrics.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.documentSplitter != null && Object.hasOwnProperty.call(message, "documentSplitter")) - writer.uint32(/* id 1, wireType 0 =*/8).bool(message.documentSplitter); - if (message.documentAllowMultipleLabels != null && Object.hasOwnProperty.call(message, "documentAllowMultipleLabels")) - writer.uint32(/* id 2, wireType 0 =*/16).bool(message.documentAllowMultipleLabels); - if (message.prefixedNamingOnProperties != null && Object.hasOwnProperty.call(message, "prefixedNamingOnProperties")) - writer.uint32(/* id 6, wireType 0 =*/48).bool(message.prefixedNamingOnProperties); - if (message.skipNamingValidation != null && Object.hasOwnProperty.call(message, "skipNamingValidation")) - writer.uint32(/* id 7, wireType 0 =*/56).bool(message.skipNamingValidation); + if (message.confidenceLevelMetrics != null && message.confidenceLevelMetrics.length) + for (var i = 0; i < message.confidenceLevelMetrics.length; ++i) + $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.encode(message.confidenceLevelMetrics[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.auprc != null && Object.hasOwnProperty.call(message, "auprc")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.auprc); + if (message.estimatedCalibrationError != null && Object.hasOwnProperty.call(message, "estimatedCalibrationError")) + writer.uint32(/* id 3, wireType 5 =*/29).float(message.estimatedCalibrationError); + if (message.confidenceLevelMetricsExact != null && message.confidenceLevelMetricsExact.length) + for (var i = 0; i < message.confidenceLevelMetricsExact.length; ++i) + $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.encode(message.confidenceLevelMetricsExact[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.auprcExact != null && Object.hasOwnProperty.call(message, "auprcExact")) + writer.uint32(/* id 5, wireType 5 =*/45).float(message.auprcExact); + if (message.estimatedCalibrationErrorExact != null && Object.hasOwnProperty.call(message, "estimatedCalibrationErrorExact")) + writer.uint32(/* id 6, wireType 5 =*/53).float(message.estimatedCalibrationErrorExact); + if (message.metricsType != null && Object.hasOwnProperty.call(message, "metricsType")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.metricsType); return writer; }; /** - * Encodes the specified Metadata message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.DocumentSchema.Metadata.verify|verify} messages. + * Encodes the specified MultiConfidenceMetrics message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.verify|verify} messages. * @function encodeDelimited - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.IMetadata} message Metadata message or plain object to encode + * @param {google.cloud.documentai.v1beta3.Evaluation.IMultiConfidenceMetrics} message MultiConfidenceMetrics message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - Metadata.encodeDelimited = function encodeDelimited(message, writer) { + MultiConfidenceMetrics.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a Metadata message from the specified reader or buffer. + * Decodes a MultiConfidenceMetrics message from the specified reader or buffer. * @function decode - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.Metadata} Metadata + * @returns {google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics} MultiConfidenceMetrics * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - Metadata.decode = function decode(reader, length) { + MultiConfidenceMetrics.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.documentSplitter = reader.bool(); + if (!(message.confidenceLevelMetrics && message.confidenceLevelMetrics.length)) + message.confidenceLevelMetrics = []; + message.confidenceLevelMetrics.push($root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.decode(reader, reader.uint32())); + break; + } + case 4: { + if (!(message.confidenceLevelMetricsExact && message.confidenceLevelMetricsExact.length)) + message.confidenceLevelMetricsExact = []; + message.confidenceLevelMetricsExact.push($root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.decode(reader, reader.uint32())); break; } case 2: { - message.documentAllowMultipleLabels = reader.bool(); + message.auprc = reader.float(); + break; + } + case 3: { + message.estimatedCalibrationError = reader.float(); + break; + } + case 5: { + message.auprcExact = reader.float(); break; } case 6: { - message.prefixedNamingOnProperties = reader.bool(); + message.estimatedCalibrationErrorExact = reader.float(); break; } case 7: { - message.skipNamingValidation = reader.bool(); + message.metricsType = reader.int32(); break; } default: @@ -76940,130 +81998,223 @@ }; /** - * Decodes a Metadata message from the specified reader or buffer, length delimited. + * Decodes a MultiConfidenceMetrics message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.Metadata} Metadata + * @returns {google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics} MultiConfidenceMetrics * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - Metadata.decodeDelimited = function decodeDelimited(reader) { + MultiConfidenceMetrics.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a Metadata message. + * Verifies a MultiConfidenceMetrics message. * @function verify - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - Metadata.verify = function verify(message) { + MultiConfidenceMetrics.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.documentSplitter != null && message.hasOwnProperty("documentSplitter")) - if (typeof message.documentSplitter !== "boolean") - return "documentSplitter: boolean expected"; - if (message.documentAllowMultipleLabels != null && message.hasOwnProperty("documentAllowMultipleLabels")) - if (typeof message.documentAllowMultipleLabels !== "boolean") - return "documentAllowMultipleLabels: boolean expected"; - if (message.prefixedNamingOnProperties != null && message.hasOwnProperty("prefixedNamingOnProperties")) - if (typeof message.prefixedNamingOnProperties !== "boolean") - return "prefixedNamingOnProperties: boolean expected"; - if (message.skipNamingValidation != null && message.hasOwnProperty("skipNamingValidation")) - if (typeof message.skipNamingValidation !== "boolean") - return "skipNamingValidation: boolean expected"; + if (message.confidenceLevelMetrics != null && message.hasOwnProperty("confidenceLevelMetrics")) { + if (!Array.isArray(message.confidenceLevelMetrics)) + return "confidenceLevelMetrics: array expected"; + for (var i = 0; i < message.confidenceLevelMetrics.length; ++i) { + var error = $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.verify(message.confidenceLevelMetrics[i]); + if (error) + return "confidenceLevelMetrics." + error; + } + } + if (message.confidenceLevelMetricsExact != null && message.hasOwnProperty("confidenceLevelMetricsExact")) { + if (!Array.isArray(message.confidenceLevelMetricsExact)) + return "confidenceLevelMetricsExact: array expected"; + for (var i = 0; i < message.confidenceLevelMetricsExact.length; ++i) { + var error = $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.verify(message.confidenceLevelMetricsExact[i]); + if (error) + return "confidenceLevelMetricsExact." + error; + } + } + if (message.auprc != null && message.hasOwnProperty("auprc")) + if (typeof message.auprc !== "number") + return "auprc: number expected"; + if (message.estimatedCalibrationError != null && message.hasOwnProperty("estimatedCalibrationError")) + if (typeof message.estimatedCalibrationError !== "number") + return "estimatedCalibrationError: number expected"; + if (message.auprcExact != null && message.hasOwnProperty("auprcExact")) + if (typeof message.auprcExact !== "number") + return "auprcExact: number expected"; + if (message.estimatedCalibrationErrorExact != null && message.hasOwnProperty("estimatedCalibrationErrorExact")) + if (typeof message.estimatedCalibrationErrorExact !== "number") + return "estimatedCalibrationErrorExact: number expected"; + if (message.metricsType != null && message.hasOwnProperty("metricsType")) + switch (message.metricsType) { + default: + return "metricsType: enum value expected"; + case 0: + case 1: + break; + } return null; }; /** - * Creates a Metadata message from a plain object. Also converts values to their respective internal types. + * Creates a MultiConfidenceMetrics message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @static * @param {Object.} object Plain object - * @returns {google.cloud.documentai.v1beta3.DocumentSchema.Metadata} Metadata + * @returns {google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics} MultiConfidenceMetrics */ - Metadata.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata) + MultiConfidenceMetrics.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics) return object; - var message = new $root.google.cloud.documentai.v1beta3.DocumentSchema.Metadata(); - if (object.documentSplitter != null) - message.documentSplitter = Boolean(object.documentSplitter); - if (object.documentAllowMultipleLabels != null) - message.documentAllowMultipleLabels = Boolean(object.documentAllowMultipleLabels); - if (object.prefixedNamingOnProperties != null) - message.prefixedNamingOnProperties = Boolean(object.prefixedNamingOnProperties); - if (object.skipNamingValidation != null) - message.skipNamingValidation = Boolean(object.skipNamingValidation); + var message = new $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics(); + if (object.confidenceLevelMetrics) { + if (!Array.isArray(object.confidenceLevelMetrics)) + throw TypeError(".google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.confidenceLevelMetrics: array expected"); + message.confidenceLevelMetrics = []; + for (var i = 0; i < object.confidenceLevelMetrics.length; ++i) { + if (typeof object.confidenceLevelMetrics[i] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.confidenceLevelMetrics: object expected"); + message.confidenceLevelMetrics[i] = $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.fromObject(object.confidenceLevelMetrics[i]); + } + } + if (object.confidenceLevelMetricsExact) { + if (!Array.isArray(object.confidenceLevelMetricsExact)) + throw TypeError(".google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.confidenceLevelMetricsExact: array expected"); + message.confidenceLevelMetricsExact = []; + for (var i = 0; i < object.confidenceLevelMetricsExact.length; ++i) { + if (typeof object.confidenceLevelMetricsExact[i] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.confidenceLevelMetricsExact: object expected"); + message.confidenceLevelMetricsExact[i] = $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.fromObject(object.confidenceLevelMetricsExact[i]); + } + } + if (object.auprc != null) + message.auprc = Number(object.auprc); + if (object.estimatedCalibrationError != null) + message.estimatedCalibrationError = Number(object.estimatedCalibrationError); + if (object.auprcExact != null) + message.auprcExact = Number(object.auprcExact); + if (object.estimatedCalibrationErrorExact != null) + message.estimatedCalibrationErrorExact = Number(object.estimatedCalibrationErrorExact); + switch (object.metricsType) { + default: + if (typeof object.metricsType === "number") { + message.metricsType = object.metricsType; + break; + } + break; + case "METRICS_TYPE_UNSPECIFIED": + case 0: + message.metricsType = 0; + break; + case "AGGREGATE": + case 1: + message.metricsType = 1; + break; + } return message; }; /** - * Creates a plain object from a Metadata message. Also converts values to other types if specified. + * Creates a plain object from a MultiConfidenceMetrics message. Also converts values to other types if specified. * @function toObject - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @static - * @param {google.cloud.documentai.v1beta3.DocumentSchema.Metadata} message Metadata + * @param {google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics} message MultiConfidenceMetrics * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - Metadata.toObject = function toObject(message, options) { + MultiConfidenceMetrics.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.defaults) { - object.documentSplitter = false; - object.documentAllowMultipleLabels = false; - object.prefixedNamingOnProperties = false; - object.skipNamingValidation = false; + if (options.arrays || options.defaults) { + object.confidenceLevelMetrics = []; + object.confidenceLevelMetricsExact = []; } - if (message.documentSplitter != null && message.hasOwnProperty("documentSplitter")) - object.documentSplitter = message.documentSplitter; - if (message.documentAllowMultipleLabels != null && message.hasOwnProperty("documentAllowMultipleLabels")) - object.documentAllowMultipleLabels = message.documentAllowMultipleLabels; - if (message.prefixedNamingOnProperties != null && message.hasOwnProperty("prefixedNamingOnProperties")) - object.prefixedNamingOnProperties = message.prefixedNamingOnProperties; - if (message.skipNamingValidation != null && message.hasOwnProperty("skipNamingValidation")) - object.skipNamingValidation = message.skipNamingValidation; + if (options.defaults) { + object.auprc = 0; + object.estimatedCalibrationError = 0; + object.auprcExact = 0; + object.estimatedCalibrationErrorExact = 0; + object.metricsType = options.enums === String ? "METRICS_TYPE_UNSPECIFIED" : 0; + } + if (message.confidenceLevelMetrics && message.confidenceLevelMetrics.length) { + object.confidenceLevelMetrics = []; + for (var j = 0; j < message.confidenceLevelMetrics.length; ++j) + object.confidenceLevelMetrics[j] = $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.toObject(message.confidenceLevelMetrics[j], options); + } + if (message.auprc != null && message.hasOwnProperty("auprc")) + object.auprc = options.json && !isFinite(message.auprc) ? String(message.auprc) : message.auprc; + if (message.estimatedCalibrationError != null && message.hasOwnProperty("estimatedCalibrationError")) + object.estimatedCalibrationError = options.json && !isFinite(message.estimatedCalibrationError) ? String(message.estimatedCalibrationError) : message.estimatedCalibrationError; + if (message.confidenceLevelMetricsExact && message.confidenceLevelMetricsExact.length) { + object.confidenceLevelMetricsExact = []; + for (var j = 0; j < message.confidenceLevelMetricsExact.length; ++j) + object.confidenceLevelMetricsExact[j] = $root.google.cloud.documentai.v1beta3.Evaluation.ConfidenceLevelMetrics.toObject(message.confidenceLevelMetricsExact[j], options); + } + if (message.auprcExact != null && message.hasOwnProperty("auprcExact")) + object.auprcExact = options.json && !isFinite(message.auprcExact) ? String(message.auprcExact) : message.auprcExact; + if (message.estimatedCalibrationErrorExact != null && message.hasOwnProperty("estimatedCalibrationErrorExact")) + object.estimatedCalibrationErrorExact = options.json && !isFinite(message.estimatedCalibrationErrorExact) ? String(message.estimatedCalibrationErrorExact) : message.estimatedCalibrationErrorExact; + if (message.metricsType != null && message.hasOwnProperty("metricsType")) + object.metricsType = options.enums === String ? $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.MetricsType[message.metricsType] === undefined ? message.metricsType : $root.google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.MetricsType[message.metricsType] : message.metricsType; return object; }; /** - * Converts this Metadata to JSON. + * Converts this MultiConfidenceMetrics to JSON. * @function toJSON - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @instance * @returns {Object.} JSON object */ - Metadata.prototype.toJSON = function toJSON() { + MultiConfidenceMetrics.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for Metadata + * Gets the default type url for MultiConfidenceMetrics * @function getTypeUrl - * @memberof google.cloud.documentai.v1beta3.DocumentSchema.Metadata + * @memberof google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - Metadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + MultiConfidenceMetrics.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.cloud.documentai.v1beta3.DocumentSchema.Metadata"; + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics"; }; - return Metadata; + /** + * MetricsType enum. + * @name google.cloud.documentai.v1beta3.Evaluation.MultiConfidenceMetrics.MetricsType + * @enum {number} + * @property {number} METRICS_TYPE_UNSPECIFIED=0 METRICS_TYPE_UNSPECIFIED value + * @property {number} AGGREGATE=1 AGGREGATE value + */ + MultiConfidenceMetrics.MetricsType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "METRICS_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "AGGREGATE"] = 1; + return values; + })(); + + return MultiConfidenceMetrics; })(); - return DocumentSchema; + return Evaluation; })(); v1beta3.CommonOperationMetadata = (function() { @@ -77441,6 +82592,7 @@ * @interface IProcessorVersion * @property {string|null} [name] ProcessorVersion name * @property {string|null} [displayName] ProcessorVersion displayName + * @property {google.cloud.documentai.v1beta3.IDocumentSchema|null} [documentSchema] ProcessorVersion documentSchema * @property {google.cloud.documentai.v1beta3.ProcessorVersion.State|null} [state] ProcessorVersion state * @property {google.protobuf.ITimestamp|null} [createTime] ProcessorVersion createTime * @property {string|null} [kmsKeyName] ProcessorVersion kmsKeyName @@ -77480,6 +82632,14 @@ */ ProcessorVersion.prototype.displayName = ""; + /** + * ProcessorVersion documentSchema. + * @member {google.cloud.documentai.v1beta3.IDocumentSchema|null|undefined} documentSchema + * @memberof google.cloud.documentai.v1beta3.ProcessorVersion + * @instance + */ + ProcessorVersion.prototype.documentSchema = null; + /** * ProcessorVersion state. * @member {google.cloud.documentai.v1beta3.ProcessorVersion.State} state @@ -77566,6 +82726,8 @@ writer.uint32(/* id 10, wireType 2 =*/82).string(message.kmsKeyVersionName); if (message.googleManaged != null && Object.hasOwnProperty.call(message, "googleManaged")) writer.uint32(/* id 11, wireType 0 =*/88).bool(message.googleManaged); + if (message.documentSchema != null && Object.hasOwnProperty.call(message, "documentSchema")) + $root.google.cloud.documentai.v1beta3.DocumentSchema.encode(message.documentSchema, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); if (message.deprecationInfo != null && Object.hasOwnProperty.call(message, "deprecationInfo")) $root.google.cloud.documentai.v1beta3.ProcessorVersion.DeprecationInfo.encode(message.deprecationInfo, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim(); return writer; @@ -77610,6 +82772,10 @@ message.displayName = reader.string(); break; } + case 12: { + message.documentSchema = $root.google.cloud.documentai.v1beta3.DocumentSchema.decode(reader, reader.uint32()); + break; + } case 6: { message.state = reader.int32(); break; @@ -77675,6 +82841,11 @@ if (message.displayName != null && message.hasOwnProperty("displayName")) if (!$util.isString(message.displayName)) return "displayName: string expected"; + if (message.documentSchema != null && message.hasOwnProperty("documentSchema")) { + var error = $root.google.cloud.documentai.v1beta3.DocumentSchema.verify(message.documentSchema); + if (error) + return "documentSchema." + error; + } if (message.state != null && message.hasOwnProperty("state")) switch (message.state) { default: @@ -77727,6 +82898,11 @@ message.name = String(object.name); if (object.displayName != null) message.displayName = String(object.displayName); + if (object.documentSchema != null) { + if (typeof object.documentSchema !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.ProcessorVersion.documentSchema: object expected"); + message.documentSchema = $root.google.cloud.documentai.v1beta3.DocumentSchema.fromObject(object.documentSchema); + } switch (object.state) { default: if (typeof object.state === "number") { @@ -77807,6 +82983,7 @@ object.kmsKeyName = ""; object.kmsKeyVersionName = ""; object.googleManaged = false; + object.documentSchema = null; object.deprecationInfo = null; } if (message.name != null && message.hasOwnProperty("name")) @@ -77823,6 +83000,8 @@ object.kmsKeyVersionName = message.kmsKeyVersionName; if (message.googleManaged != null && message.hasOwnProperty("googleManaged")) object.googleManaged = message.googleManaged; + if (message.documentSchema != null && message.hasOwnProperty("documentSchema")) + object.documentSchema = $root.google.cloud.documentai.v1beta3.DocumentSchema.toObject(message.documentSchema, options); if (message.deprecationInfo != null && message.hasOwnProperty("deprecationInfo")) object.deprecationInfo = $root.google.cloud.documentai.v1beta3.ProcessorVersion.DeprecationInfo.toObject(message.deprecationInfo, options); return object; diff --git a/packages/google-cloud-documentai/protos/protos.json b/packages/google-cloud-documentai/protos/protos.json index f8ada9d376b..90f36807e1c 100644 --- a/packages/google-cloud-documentai/protos/protos.json +++ b/packages/google-cloud-documentai/protos/protos.json @@ -4414,6 +4414,10 @@ "fontSize": { "type": "FontSize", "id": 7 + }, + "fontFamily": { + "type": "string", + "id": 8 } }, "nested": { @@ -4504,9 +4508,16 @@ "type": "DetectedBarcode", "id": 15 }, + "imageQualityScores": { + "type": "ImageQualityScores", + "id": 17 + }, "provenance": { "type": "Provenance", - "id": 16 + "id": 16, + "options": { + "deprecated": true + } } }, "nested": { @@ -4610,7 +4621,10 @@ }, "provenance": { "type": "Provenance", - "id": 3 + "id": 3, + "options": { + "deprecated": true + } } } }, @@ -4627,7 +4641,10 @@ }, "provenance": { "type": "Provenance", - "id": 3 + "id": 3, + "options": { + "deprecated": true + } } } }, @@ -4644,7 +4661,10 @@ }, "provenance": { "type": "Provenance", - "id": 3 + "id": 3, + "options": { + "deprecated": true + } } } }, @@ -4665,7 +4685,10 @@ }, "provenance": { "type": "Provenance", - "id": 4 + "id": 4, + "options": { + "deprecated": true + } } }, "nested": { @@ -4739,6 +4762,10 @@ "rule": "repeated", "type": "DetectedLanguage", "id": 4 + }, + "provenance": { + "type": "Provenance", + "id": 5 } }, "nested": { @@ -4835,6 +4862,33 @@ "id": 2 } } + }, + "ImageQualityScores": { + "fields": { + "qualityScore": { + "type": "float", + "id": 1 + }, + "detectedDefects": { + "rule": "repeated", + "type": "DetectedDefect", + "id": 2 + } + }, + "nested": { + "DetectedDefect": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "confidence": { + "type": "float", + "id": 2 + } + } + } + } } } }, @@ -5210,7 +5264,10 @@ "provenance": { "rule": "repeated", "type": "Provenance", - "id": 3 + "id": 3, + "options": { + "deprecated": true + } } } } @@ -5335,6 +5392,10 @@ "gcsUri": { "type": "string", "id": 1 + }, + "fieldMask": { + "type": "google.protobuf.FieldMask", + "id": 2 } } } @@ -5478,6 +5539,34 @@ } ] }, + "TrainProcessorVersion": { + "requestType": "TrainProcessorVersionRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v1beta3/{parent=projects/*/locations/*/processors/*}/processorVersions:train", + "(google.api.http).body": "*", + "(google.api.method_signature)": "parent,processor_version", + "(google.longrunning.operation_info).response_type": "TrainProcessorVersionResponse", + "(google.longrunning.operation_info).metadata_type": "TrainProcessorVersionMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta3/{parent=projects/*/locations/*/processors/*}/processorVersions:train", + "body": "*" + } + }, + { + "(google.api.method_signature)": "parent,processor_version" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "TrainProcessorVersionResponse", + "metadata_type": "TrainProcessorVersionMetadata" + } + } + ] + }, "GetProcessorVersion": { "requestType": "GetProcessorVersionRequest", "responseType": "ProcessorVersion", @@ -5741,6 +5830,70 @@ } } ] + }, + "EvaluateProcessorVersion": { + "requestType": "EvaluateProcessorVersionRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v1beta3/{processor_version=projects/*/locations/*/processors/*/processorVersions/*}:evaluateProcessorVersion", + "(google.api.http).body": "*", + "(google.api.method_signature)": "processor_version", + "(google.longrunning.operation_info).response_type": "EvaluateProcessorVersionResponse", + "(google.longrunning.operation_info).metadata_type": "EvaluateProcessorVersionMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta3/{processor_version=projects/*/locations/*/processors/*/processorVersions/*}:evaluateProcessorVersion", + "body": "*" + } + }, + { + "(google.api.method_signature)": "processor_version" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "EvaluateProcessorVersionResponse", + "metadata_type": "EvaluateProcessorVersionMetadata" + } + } + ] + }, + "GetEvaluation": { + "requestType": "GetEvaluationRequest", + "responseType": "Evaluation", + "options": { + "(google.api.http).get": "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*/evaluations/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1beta3/{name=projects/*/locations/*/processors/*/processorVersions/*/evaluations/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListEvaluations": { + "requestType": "ListEvaluationsRequest", + "responseType": "ListEvaluationsResponse", + "options": { + "(google.api.http).get": "/v1beta3/{parent=projects/*/locations/*/processors/*/processorVersions/*}/evaluations", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1beta3/{parent=projects/*/locations/*/processors/*/processorVersions/*}/evaluations" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] } } }, @@ -6294,6 +6447,108 @@ } } }, + "TrainProcessorVersionRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "documentai.googleapis.com/ProcessorVersion" + } + }, + "processorVersion": { + "type": "ProcessorVersion", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "documentSchema": { + "type": "DocumentSchema", + "id": 10, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "inputData": { + "type": "InputData", + "id": 4, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "baseProcessorVersion": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + }, + "nested": { + "InputData": { + "fields": { + "trainingDocuments": { + "type": "BatchDocumentsInputConfig", + "id": 3 + }, + "testDocuments": { + "type": "BatchDocumentsInputConfig", + "id": 4 + } + } + } + } + }, + "TrainProcessorVersionResponse": { + "fields": { + "processorVersion": { + "type": "string", + "id": 1 + } + } + }, + "TrainProcessorVersionMetadata": { + "fields": { + "commonMetadata": { + "type": "CommonOperationMetadata", + "id": 1 + }, + "trainingDatasetValidation": { + "type": "DatasetValidation", + "id": 2 + }, + "testDatasetValidation": { + "type": "DatasetValidation", + "id": 3 + } + }, + "nested": { + "DatasetValidation": { + "fields": { + "documentErrorCount": { + "type": "int32", + "id": 3 + }, + "datasetErrorCount": { + "type": "int32", + "id": 4 + }, + "documentErrors": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 1 + }, + "datasetErrors": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 2 + } + } + } + } + }, "ReviewDocumentRequest": { "oneofs": { "source": { @@ -6409,6 +6664,86 @@ } } }, + "EvaluateProcessorVersionRequest": { + "fields": { + "processorVersion": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "documentai.googleapis.com/ProcessorVersion" + } + }, + "evaluationDocuments": { + "type": "BatchDocumentsInputConfig", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "EvaluateProcessorVersionMetadata": { + "fields": { + "commonMetadata": { + "type": "CommonOperationMetadata", + "id": 1 + } + } + }, + "EvaluateProcessorVersionResponse": { + "fields": { + "evaluation": { + "type": "string", + "id": 2 + } + } + }, + "GetEvaluationRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "documentai.googleapis.com/Evaluation" + } + } + } + }, + "ListEvaluationsRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "documentai.googleapis.com/ProcessorVersion" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + } + } + }, + "ListEvaluationsResponse": { + "fields": { + "evaluations": { + "rule": "repeated", + "type": "Evaluation", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, "DocumentSchema": { "fields": { "displayName": { @@ -6523,6 +6858,167 @@ } } }, + "Evaluation": { + "options": { + "(google.api.resource).type": "documentai.googleapis.com/Evaluation", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation}" + }, + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "documentCounters": { + "type": "Counters", + "id": 5 + }, + "allEntitiesMetrics": { + "type": "MultiConfidenceMetrics", + "id": 3 + }, + "entityMetrics": { + "keyType": "string", + "type": "MultiConfidenceMetrics", + "id": 4 + }, + "kmsKeyName": { + "type": "string", + "id": 6 + }, + "kmsKeyVersionName": { + "type": "string", + "id": 7 + } + }, + "nested": { + "Counters": { + "fields": { + "inputDocumentsCount": { + "type": "int32", + "id": 1 + }, + "invalidDocumentsCount": { + "type": "int32", + "id": 2 + }, + "failedDocumentsCount": { + "type": "int32", + "id": 3 + }, + "evaluatedDocumentsCount": { + "type": "int32", + "id": 4 + } + } + }, + "Metrics": { + "fields": { + "precision": { + "type": "float", + "id": 1 + }, + "recall": { + "type": "float", + "id": 2 + }, + "f1Score": { + "type": "float", + "id": 3 + }, + "predictedOccurrencesCount": { + "type": "int32", + "id": 4 + }, + "groundTruthOccurrencesCount": { + "type": "int32", + "id": 5 + }, + "predictedDocumentCount": { + "type": "int32", + "id": 10 + }, + "groundTruthDocumentCount": { + "type": "int32", + "id": 11 + }, + "truePositivesCount": { + "type": "int32", + "id": 6 + }, + "falsePositivesCount": { + "type": "int32", + "id": 7 + }, + "falseNegativesCount": { + "type": "int32", + "id": 8 + }, + "totalDocumentsCount": { + "type": "int32", + "id": 9 + } + } + }, + "ConfidenceLevelMetrics": { + "fields": { + "confidenceLevel": { + "type": "float", + "id": 1 + }, + "metrics": { + "type": "Metrics", + "id": 2 + } + } + }, + "MultiConfidenceMetrics": { + "fields": { + "confidenceLevelMetrics": { + "rule": "repeated", + "type": "ConfidenceLevelMetrics", + "id": 1 + }, + "confidenceLevelMetricsExact": { + "rule": "repeated", + "type": "ConfidenceLevelMetrics", + "id": 4 + }, + "auprc": { + "type": "float", + "id": 2 + }, + "estimatedCalibrationError": { + "type": "float", + "id": 3 + }, + "auprcExact": { + "type": "float", + "id": 5 + }, + "estimatedCalibrationErrorExact": { + "type": "float", + "id": 6 + }, + "metricsType": { + "type": "MetricsType", + "id": 7 + } + }, + "nested": { + "MetricsType": { + "values": { + "METRICS_TYPE_UNSPECIFIED": 0, + "AGGREGATE": 1 + } + } + } + } + } + }, "CommonOperationMetadata": { "fields": { "state": { @@ -6573,6 +7069,10 @@ "type": "string", "id": 2 }, + "documentSchema": { + "type": "DocumentSchema", + "id": 12 + }, "state": { "type": "State", "id": 6 diff --git a/packages/google-cloud-documentai/samples/README.md b/packages/google-cloud-documentai/samples/README.md index c3fdc979a96..28100b4a64c 100644 --- a/packages/google-cloud-documentai/samples/README.md +++ b/packages/google-cloud-documentai/samples/README.md @@ -39,15 +39,19 @@ * [Document_processor_service.deploy_processor_version](#document_processor_service.deploy_processor_version) * [Document_processor_service.disable_processor](#document_processor_service.disable_processor) * [Document_processor_service.enable_processor](#document_processor_service.enable_processor) + * [Document_processor_service.evaluate_processor_version](#document_processor_service.evaluate_processor_version) * [Document_processor_service.fetch_processor_types](#document_processor_service.fetch_processor_types) + * [Document_processor_service.get_evaluation](#document_processor_service.get_evaluation) * [Document_processor_service.get_processor](#document_processor_service.get_processor) * [Document_processor_service.get_processor_version](#document_processor_service.get_processor_version) + * [Document_processor_service.list_evaluations](#document_processor_service.list_evaluations) * [Document_processor_service.list_processor_types](#document_processor_service.list_processor_types) * [Document_processor_service.list_processor_versions](#document_processor_service.list_processor_versions) * [Document_processor_service.list_processors](#document_processor_service.list_processors) * [Document_processor_service.process_document](#document_processor_service.process_document) * [Document_processor_service.review_document](#document_processor_service.review_document) * [Document_processor_service.set_default_processor_version](#document_processor_service.set_default_processor_version) + * [Document_processor_service.train_processor_version](#document_processor_service.train_processor_version) * [Document_processor_service.undeploy_processor_version](#document_processor_service.undeploy_processor_version) * [Quickstart](#quickstart) * [Quickstart.test](#quickstart.test) @@ -526,6 +530,23 @@ __Usage:__ +### Document_processor_service.evaluate_processor_version + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js` + + +----- + + + + ### Document_processor_service.fetch_processor_types View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.fetch_processor_types.js). @@ -543,6 +564,23 @@ __Usage:__ +### Document_processor_service.get_evaluation + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_evaluation.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_evaluation.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_evaluation.js` + + +----- + + + + ### Document_processor_service.get_processor View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_processor.js). @@ -577,6 +615,23 @@ __Usage:__ +### Document_processor_service.list_evaluations + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_evaluations.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_evaluations.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_evaluations.js` + + +----- + + + + ### Document_processor_service.list_processor_types View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_processor_types.js). @@ -679,6 +734,23 @@ __Usage:__ +### Document_processor_service.train_processor_version + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.train_processor_version.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.train_processor_version.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.train_processor_version.js` + + +----- + + + + ### Document_processor_service.undeploy_processor_version View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.undeploy_processor_version.js). diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js b/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js similarity index 100% rename from owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js rename to packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_evaluation.js b/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_evaluation.js similarity index 100% rename from owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.get_evaluation.js rename to packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.get_evaluation.js diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_evaluations.js b/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_evaluations.js similarity index 100% rename from owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.list_evaluations.js rename to packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.list_evaluations.js diff --git a/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.process_document.js b/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.process_document.js index 1a6657cabc9..b64abecbc4c 100644 --- a/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.process_document.js +++ b/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.process_document.js @@ -56,6 +56,8 @@ function main(name) { // const skipHumanReview = true /** * Specifies which fields to include in ProcessResponse's document. + * Only supports top level document and pages field so it must be in the form + * of `{document_field_name}` or `pages.{page_field_name}`. */ // const fieldMask = {} diff --git a/owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.train_processor_version.js b/packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.train_processor_version.js similarity index 100% rename from owl-bot-staging/google-cloud-documentai/v1beta3/samples/generated/v1beta3/document_processor_service.train_processor_version.js rename to packages/google-cloud-documentai/samples/generated/v1beta3/document_processor_service.train_processor_version.js diff --git a/packages/google-cloud-documentai/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json b/packages/google-cloud-documentai/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json index bd2acbac3df..ab0ad8ef8f7 100644 --- a/packages/google-cloud-documentai/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json +++ b/packages/google-cloud-documentai/samples/generated/v1beta3/snippet_metadata.google.cloud.documentai.v1beta3.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 79, + "end": 81, "type": "FULL" } ], @@ -307,6 +307,62 @@ } } }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async", + "title": "DocumentProcessorService trainProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Trains a new processor version. Operation metadata is returned as cloud_documentai_core.TrainProcessorVersionMetadata.", + "canonical": true, + "file": "document_processor_service.train_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TrainProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.TrainProcessorVersion", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "processor_version", + "type": ".google.cloud.documentai.v1beta3.ProcessorVersion" + }, + { + "name": "document_schema", + "type": ".google.cloud.documentai.v1beta3.DocumentSchema" + }, + { + "name": "input_data", + "type": ".google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData" + }, + { + "name": "base_processor_version", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "TrainProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.TrainProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, { "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_GetProcessorVersion_async", "title": "DocumentProcessorService getProcessorVersion Sample", @@ -782,6 +838,138 @@ } } } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async", + "title": "DocumentProcessorService evaluateProcessorVersion Sample", + "origin": "API_DEFINITION", + "description": " Evaluates a ProcessorVersion against annotated documents, producing an Evaluation.", + "canonical": true, + "file": "document_processor_service.evaluate_processor_version.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "EvaluateProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EvaluateProcessorVersion", + "async": true, + "parameters": [ + { + "name": "processor_version", + "type": "TYPE_STRING" + }, + { + "name": "evaluation_documents", + "type": ".google.cloud.documentai.v1beta3.BatchDocumentsInputConfig" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "EvaluateProcessorVersion", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.EvaluateProcessorVersion", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_GetEvaluation_async", + "title": "DocumentProcessorService getEvaluation Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a specific evaluation.", + "canonical": true, + "file": "document_processor_service.get_evaluation.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetEvaluation", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetEvaluation", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.Evaluation", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "GetEvaluation", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.GetEvaluation", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } + }, + { + "regionTag": "documentai_v1beta3_generated_DocumentProcessorService_ListEvaluations_async", + "title": "DocumentProcessorService listEvaluations Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a set of evaluations for a given processor version.", + "canonical": true, + "file": "document_processor_service.list_evaluations.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListEvaluations", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListEvaluations", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.documentai.v1beta3.ListEvaluationsResponse", + "client": { + "shortName": "DocumentProcessorServiceClient", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorServiceClient" + }, + "method": { + "shortName": "ListEvaluations", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService.ListEvaluations", + "service": { + "shortName": "DocumentProcessorService", + "fullName": "google.cloud.documentai.v1beta3.DocumentProcessorService" + } + } + } } ] } \ No newline at end of file diff --git a/packages/google-cloud-documentai/src/v1/document_processor_service_client.ts b/packages/google-cloud-documentai/src/v1/document_processor_service_client.ts index 33fffdda1f0..a1045c0d373 100644 --- a/packages/google-cloud-documentai/src/v1/document_processor_service_client.ts +++ b/packages/google-cloud-documentai/src/v1/document_processor_service_client.ts @@ -130,8 +130,11 @@ export class DocumentProcessorServiceClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - // If scopes are unset in options set scopes. - if (!('scopes' in opts)) { + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -158,6 +161,10 @@ export class DocumentProcessorServiceClient { // Set defaultServicePath on the auth object. this.auth.defaultServicePath = staticMembers.servicePath; + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, opts diff --git a/packages/google-cloud-documentai/src/v1beta1/document_understanding_service_client.ts b/packages/google-cloud-documentai/src/v1beta1/document_understanding_service_client.ts index edd67bc8609..0e5f2654c67 100644 --- a/packages/google-cloud-documentai/src/v1beta1/document_understanding_service_client.ts +++ b/packages/google-cloud-documentai/src/v1beta1/document_understanding_service_client.ts @@ -123,8 +123,11 @@ export class DocumentUnderstandingServiceClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - // If scopes are unset in options set scopes. - if (!('scopes' in opts)) { + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,6 +154,11 @@ export class DocumentUnderstandingServiceClient { // Set defaultServicePath on the auth object. this.auth.defaultServicePath = staticMembers.servicePath; + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { diff --git a/packages/google-cloud-documentai/src/v1beta2/document_understanding_service_client.ts b/packages/google-cloud-documentai/src/v1beta2/document_understanding_service_client.ts index 295893caf18..9b8023969d9 100644 --- a/packages/google-cloud-documentai/src/v1beta2/document_understanding_service_client.ts +++ b/packages/google-cloud-documentai/src/v1beta2/document_understanding_service_client.ts @@ -123,8 +123,11 @@ export class DocumentUnderstandingServiceClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - // If scopes are unset in options set scopes. - if (!('scopes' in opts)) { + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -151,6 +154,11 @@ export class DocumentUnderstandingServiceClient { // Set defaultServicePath on the auth object. this.auth.defaultServicePath = staticMembers.servicePath; + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + // Determine the client header string. const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { diff --git a/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client.ts b/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client.ts index 230e98be983..8f17822972f 100644 --- a/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client.ts +++ b/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client.ts @@ -130,8 +130,11 @@ export class DocumentProcessorServiceClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - // If scopes are unset in options set scopes. - if (!('scopes' in opts)) { + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; } @@ -158,6 +161,10 @@ export class DocumentProcessorServiceClient { // Set defaultServicePath on the auth object. this.auth.defaultServicePath = staticMembers.servicePath; + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, opts @@ -185,6 +192,9 @@ export class DocumentProcessorServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { + evaluationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processor_version}/evaluations/{evaluation}' + ), humanReviewConfigPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/locations/{location}/processors/{processor}/humanReviewConfig' ), @@ -224,6 +234,11 @@ export class DocumentProcessorServiceClient { 'nextPageToken', 'processorVersions' ), + listEvaluations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'evaluations' + ), }; const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); @@ -285,6 +300,12 @@ export class DocumentProcessorServiceClient { const batchProcessDocumentsMetadata = protoFilesRoot.lookup( '.google.cloud.documentai.v1beta3.BatchProcessMetadata' ) as gax.protobuf.Type; + const trainProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.TrainProcessorVersionResponse' + ) as gax.protobuf.Type; + const trainProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata' + ) as gax.protobuf.Type; const deleteProcessorVersionResponse = protoFilesRoot.lookup( '.google.protobuf.Empty' ) as gax.protobuf.Type; @@ -333,6 +354,12 @@ export class DocumentProcessorServiceClient { const reviewDocumentMetadata = protoFilesRoot.lookup( '.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata' ) as gax.protobuf.Type; + const evaluateProcessorVersionResponse = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse' + ) as gax.protobuf.Type; + const evaluateProcessorVersionMetadata = protoFilesRoot.lookup( + '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata' + ) as gax.protobuf.Type; this.descriptors.longrunning = { batchProcessDocuments: new this._gaxModule.LongrunningDescriptor( @@ -342,6 +369,13 @@ export class DocumentProcessorServiceClient { ), batchProcessDocumentsMetadata.decode.bind(batchProcessDocumentsMetadata) ), + trainProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + trainProcessorVersionResponse.decode.bind( + trainProcessorVersionResponse + ), + trainProcessorVersionMetadata.decode.bind(trainProcessorVersionMetadata) + ), deleteProcessorVersion: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteProcessorVersionResponse.decode.bind( @@ -398,6 +432,15 @@ export class DocumentProcessorServiceClient { reviewDocumentResponse.decode.bind(reviewDocumentResponse), reviewDocumentMetadata.decode.bind(reviewDocumentMetadata) ), + evaluateProcessorVersion: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + evaluateProcessorVersionResponse.decode.bind( + evaluateProcessorVersionResponse + ), + evaluateProcessorVersionMetadata.decode.bind( + evaluateProcessorVersionMetadata + ) + ), }; // Put together the default options sent with requests. @@ -457,6 +500,7 @@ export class DocumentProcessorServiceClient { 'listProcessorTypes', 'listProcessors', 'getProcessor', + 'trainProcessorVersion', 'getProcessorVersion', 'listProcessorVersions', 'deleteProcessorVersion', @@ -468,6 +512,9 @@ export class DocumentProcessorServiceClient { 'disableProcessor', 'setDefaultProcessorVersion', 'reviewDocument', + 'evaluateProcessorVersion', + 'getEvaluation', + 'listEvaluations', ]; for (const methodName of documentProcessorServiceStubMethods) { const callPromise = this.documentProcessorServiceStub.then( @@ -577,6 +624,8 @@ export class DocumentProcessorServiceClient { * false. * @param {google.protobuf.FieldMask} request.fieldMask * Specifies which fields to include in ProcessResponse's document. + * Only supports top level document and pages field so it must be in the form + * of `{document_field_name}` or `pages.{page_field_name}`. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1045,6 +1094,98 @@ export class DocumentProcessorServiceClient { this.initialize(); return this.innerApiCalls.createProcessor(request, options, callback); } + /** + * Retrieves a specific evaluation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the {@link google.cloud.documentai.v1beta3.Evaluation|Evaluation} to get. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}/evaluations/{evaluation}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.get_evaluation.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_GetEvaluation_async + */ + getEvaluation( + request?: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.documentai.v1beta3.IEvaluation, + protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest | undefined, + {} | undefined + ] + >; + getEvaluation( + request: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IEvaluation, + | protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getEvaluation( + request: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, + callback: Callback< + protos.google.cloud.documentai.v1beta3.IEvaluation, + | protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getEvaluation( + request?: protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.documentai.v1beta3.IEvaluation, + | protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.documentai.v1beta3.IEvaluation, + | protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.documentai.v1beta3.IEvaluation, + protos.google.cloud.documentai.v1beta3.IGetEvaluationRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getEvaluation(request, options, callback); + } /** * LRO endpoint to batch process many documents. The output is written @@ -1200,6 +1341,157 @@ export class DocumentProcessorServiceClient { protos.google.cloud.documentai.v1beta3.BatchProcessMetadata >; } + /** + * Trains a new processor version. + * Operation metadata is returned as + * cloud_documentai_core.TrainProcessorVersionMetadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project, location and processor) to create the new version for. + * Format: `projects/{project}/locations/{location}/processors/{processor}`. + * @param {google.cloud.documentai.v1beta3.ProcessorVersion} request.processorVersion + * Required. The processor version to be created. + * @param {google.cloud.documentai.v1beta3.DocumentSchema} [request.documentSchema] + * Optional. The schema the processor version will be trained with. + * @param {google.cloud.documentai.v1beta3.TrainProcessorVersionRequest.InputData} [request.inputData] + * Optional. The input data used to train the `ProcessorVersion`. + * @param {string} [request.baseProcessorVersion] + * Optional. The processor version to use as a base for training. This processor version + * must be a child of `parent`. Format: + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.train_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async + */ + trainProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + trainProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + trainProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, + callback: Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + trainProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.trainProcessorVersion(request, options, callback); + } + /** + * Check the status of the long running operation returned by `trainProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.train_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_TrainProcessorVersion_async + */ + async checkTrainProcessorVersionProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.documentai.v1beta3.TrainProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.trainProcessorVersion, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.documentai.v1beta3.TrainProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.TrainProcessorVersionMetadata + >; + } /** * Deletes the processor version, all artifacts under the processor version * will be deleted. @@ -2340,6 +2632,153 @@ export class DocumentProcessorServiceClient { protos.google.cloud.documentai.v1beta3.ReviewDocumentOperationMetadata >; } + /** + * Evaluates a ProcessorVersion against annotated documents, producing an + * Evaluation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.processorVersion + * Required. The resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to evaluate. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @param {google.cloud.documentai.v1beta3.BatchDocumentsInputConfig} [request.evaluationDocuments] + * Optional. The documents used in the evaluation. If unspecified, use the processor's + * dataset as evaluation input. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async + */ + evaluateProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + evaluateProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + evaluateProcessorVersion( + request: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, + callback: Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + evaluateProcessorVersion( + request?: protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + processor_version: request.processorVersion ?? '', + }); + this.initialize(); + return this.innerApiCalls.evaluateProcessorVersion( + request, + options, + callback + ); + } + /** + * Check the status of the long running operation returned by `evaluateProcessorVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.evaluate_processor_version.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_EvaluateProcessorVersion_async + */ + async checkEvaluateProcessorVersionProgress( + name: string + ): Promise< + LROperation< + protos.google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + > + > { + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.evaluateProcessorVersion, + this._gaxModule.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.cloud.documentai.v1beta3.EvaluateProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.EvaluateProcessorVersionMetadata + >; + } /** * Lists the processor types that exist. * @@ -2943,6 +3382,207 @@ export class DocumentProcessorServiceClient { callSettings ) as AsyncIterable; } + /** + * Retrieves a set of evaluations for a given processor version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to list evaluations for. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @param {number} request.pageSize + * The standard list page size. + * If unspecified, at most 5 evaluations will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous `ListEvaluations` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation}. + * 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 `listEvaluationsAsync()` + * 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. + */ + listEvaluations( + request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.documentai.v1beta3.IEvaluation[], + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest | null, + protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse + ] + >; + listEvaluations( + request: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + | protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse + | null + | undefined, + protos.google.cloud.documentai.v1beta3.IEvaluation + > + ): void; + listEvaluations( + request: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + callback: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + | protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse + | null + | undefined, + protos.google.cloud.documentai.v1beta3.IEvaluation + > + ): void; + listEvaluations( + request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + | protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse + | null + | undefined, + protos.google.cloud.documentai.v1beta3.IEvaluation + >, + callback?: PaginationCallback< + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + | protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse + | null + | undefined, + protos.google.cloud.documentai.v1beta3.IEvaluation + > + ): Promise< + [ + protos.google.cloud.documentai.v1beta3.IEvaluation[], + protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest | null, + protos.google.cloud.documentai.v1beta3.IListEvaluationsResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listEvaluations(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 resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to list evaluations for. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @param {number} request.pageSize + * The standard list page size. + * If unspecified, at most 5 evaluations will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous `ListEvaluations` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation} 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 `listEvaluationsAsync()` + * 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. + */ + listEvaluationsStream( + request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listEvaluations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEvaluations.createStream( + this.innerApiCalls.listEvaluations as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listEvaluations`, 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 resource name of the {@link google.cloud.documentai.v1beta3.ProcessorVersion|ProcessorVersion} to list evaluations for. + * `projects/{project}/locations/{location}/processors/{processor}/processorVersions/{processorVersion}` + * @param {number} request.pageSize + * The standard list page size. + * If unspecified, at most 5 evaluations will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous `ListEvaluations` call. + * Provide this to retrieve the subsequent page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Evaluation]{@link google.cloud.documentai.v1beta3.Evaluation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1beta3/document_processor_service.list_evaluations.js + * region_tag:documentai_v1beta3_generated_DocumentProcessorService_ListEvaluations_async + */ + listEvaluationsAsync( + request?: protos.google.cloud.documentai.v1beta3.IListEvaluationsRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listEvaluations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listEvaluations.asyncIterate( + this.innerApiCalls['listEvaluations'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } /** * Gets information about a location. * @@ -3204,6 +3844,92 @@ export class DocumentProcessorServiceClient { // -- Path templates -- // -------------------- + /** + * Return a fully-qualified evaluation resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} processor + * @param {string} processor_version + * @param {string} evaluation + * @returns {string} Resource name string. + */ + evaluationPath( + project: string, + location: string, + processor: string, + processorVersion: string, + evaluation: string + ) { + return this.pathTemplates.evaluationPathTemplate.render({ + project: project, + location: location, + processor: processor, + processor_version: processorVersion, + evaluation: evaluation, + }); + } + + /** + * Parse the project from Evaluation resource. + * + * @param {string} evaluationName + * A fully-qualified path representing Evaluation resource. + * @returns {string} A string representing the project. + */ + matchProjectFromEvaluationName(evaluationName: string) { + return this.pathTemplates.evaluationPathTemplate.match(evaluationName) + .project; + } + + /** + * Parse the location from Evaluation resource. + * + * @param {string} evaluationName + * A fully-qualified path representing Evaluation resource. + * @returns {string} A string representing the location. + */ + matchLocationFromEvaluationName(evaluationName: string) { + return this.pathTemplates.evaluationPathTemplate.match(evaluationName) + .location; + } + + /** + * Parse the processor from Evaluation resource. + * + * @param {string} evaluationName + * A fully-qualified path representing Evaluation resource. + * @returns {string} A string representing the processor. + */ + matchProcessorFromEvaluationName(evaluationName: string) { + return this.pathTemplates.evaluationPathTemplate.match(evaluationName) + .processor; + } + + /** + * Parse the processor_version from Evaluation resource. + * + * @param {string} evaluationName + * A fully-qualified path representing Evaluation resource. + * @returns {string} A string representing the processor_version. + */ + matchProcessorVersionFromEvaluationName(evaluationName: string) { + return this.pathTemplates.evaluationPathTemplate.match(evaluationName) + .processor_version; + } + + /** + * Parse the evaluation from Evaluation resource. + * + * @param {string} evaluationName + * A fully-qualified path representing Evaluation resource. + * @returns {string} A string representing the evaluation. + */ + matchEvaluationFromEvaluationName(evaluationName: string) { + return this.pathTemplates.evaluationPathTemplate.match(evaluationName) + .evaluation; + } + /** * Return a fully-qualified humanReviewConfig resource name string. * diff --git a/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client_config.json b/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client_config.json index 7f6b23b7082..2ed5da479a8 100644 --- a/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client_config.json +++ b/packages/google-cloud-documentai/src/v1beta3/document_processor_service_client_config.json @@ -46,6 +46,10 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "TrainProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "GetProcessorVersion": { "retry_codes_name": "non_idempotent", "retry_params_name": "default" @@ -90,6 +94,18 @@ "timeout_millis": 120000, "retry_codes_name": "idempotent", "retry_params_name": "default" + }, + "EvaluateProcessorVersion": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetEvaluation": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListEvaluations": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" } } } diff --git a/packages/google-cloud-documentai/src/v1beta3/document_processor_service_proto_list.json b/packages/google-cloud-documentai/src/v1beta3/document_processor_service_proto_list.json index 8264c6d698a..673527d6d32 100644 --- a/packages/google-cloud-documentai/src/v1beta3/document_processor_service_proto_list.json +++ b/packages/google-cloud-documentai/src/v1beta3/document_processor_service_proto_list.json @@ -4,6 +4,7 @@ "../../protos/google/cloud/documentai/v1beta3/document_io.proto", "../../protos/google/cloud/documentai/v1beta3/document_processor_service.proto", "../../protos/google/cloud/documentai/v1beta3/document_schema.proto", + "../../protos/google/cloud/documentai/v1beta3/evaluation.proto", "../../protos/google/cloud/documentai/v1beta3/geometry.proto", "../../protos/google/cloud/documentai/v1beta3/operation_metadata.proto", "../../protos/google/cloud/documentai/v1beta3/processor.proto", diff --git a/packages/google-cloud-documentai/src/v1beta3/gapic_metadata.json b/packages/google-cloud-documentai/src/v1beta3/gapic_metadata.json index 120820fcb8e..5252ce974c5 100644 --- a/packages/google-cloud-documentai/src/v1beta3/gapic_metadata.json +++ b/packages/google-cloud-documentai/src/v1beta3/gapic_metadata.json @@ -35,11 +35,21 @@ "createProcessor" ] }, + "GetEvaluation": { + "methods": [ + "getEvaluation" + ] + }, "BatchProcessDocuments": { "methods": [ "batchProcessDocuments" ] }, + "TrainProcessorVersion": { + "methods": [ + "trainProcessorVersion" + ] + }, "DeleteProcessorVersion": { "methods": [ "deleteProcessorVersion" @@ -80,6 +90,11 @@ "reviewDocument" ] }, + "EvaluateProcessorVersion": { + "methods": [ + "evaluateProcessorVersion" + ] + }, "ListProcessorTypes": { "methods": [ "listProcessorTypes", @@ -100,6 +115,13 @@ "listProcessorVersionsStream", "listProcessorVersionsAsync" ] + }, + "ListEvaluations": { + "methods": [ + "listEvaluations", + "listEvaluationsStream", + "listEvaluationsAsync" + ] } } }, @@ -131,11 +153,21 @@ "createProcessor" ] }, + "GetEvaluation": { + "methods": [ + "getEvaluation" + ] + }, "BatchProcessDocuments": { "methods": [ "batchProcessDocuments" ] }, + "TrainProcessorVersion": { + "methods": [ + "trainProcessorVersion" + ] + }, "DeleteProcessorVersion": { "methods": [ "deleteProcessorVersion" @@ -176,6 +208,11 @@ "reviewDocument" ] }, + "EvaluateProcessorVersion": { + "methods": [ + "evaluateProcessorVersion" + ] + }, "ListProcessorTypes": { "methods": [ "listProcessorTypes", @@ -196,6 +233,13 @@ "listProcessorVersionsStream", "listProcessorVersionsAsync" ] + }, + "ListEvaluations": { + "methods": [ + "listEvaluations", + "listEvaluationsStream", + "listEvaluationsAsync" + ] } } } diff --git a/packages/google-cloud-documentai/test/gapic_document_processor_service_v1beta3.ts b/packages/google-cloud-documentai/test/gapic_document_processor_service_v1beta3.ts index 3791385f73f..e941eb82aaa 100644 --- a/packages/google-cloud-documentai/test/gapic_document_processor_service_v1beta3.ts +++ b/packages/google-cloud-documentai/test/gapic_document_processor_service_v1beta3.ts @@ -999,6 +999,148 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { }); }); + describe('getEvaluation', () => { + it('invokes getEvaluation 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.GetEvaluationRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.GetEvaluationRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.Evaluation() + ); + client.innerApiCalls.getEvaluation = stubSimpleCall(expectedResponse); + const [response] = await client.getEvaluation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEvaluation 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.GetEvaluationRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.GetEvaluationRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.Evaluation() + ); + client.innerApiCalls.getEvaluation = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEvaluation( + request, + ( + err?: Error | null, + result?: protos.google.cloud.documentai.v1beta3.IEvaluation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEvaluation 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.GetEvaluationRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.GetEvaluationRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEvaluation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getEvaluation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEvaluation with closed client', 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.GetEvaluationRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.GetEvaluationRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getEvaluation(request), expectedError); + }); + }); + describe('batchProcessDocuments', () => { it('invokes batchProcessDocuments without error', async () => { const client = @@ -1214,8 +1356,8 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { }); }); - describe('deleteProcessorVersion', () => { - it('invokes deleteProcessorVersion without error', async () => { + describe('trainProcessorVersion', () => { + it('invokes trainProcessorVersion without error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1225,33 +1367,33 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest() + new protos.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', - ['name'] + '.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', + ['parent'] ); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.deleteProcessorVersion = + client.innerApiCalls.trainProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteProcessorVersion(request); + const [operation] = await client.trainProcessorVersion(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); const actualRequest = ( - client.innerApiCalls.deleteProcessorVersion as SinonStub + client.innerApiCalls.trainProcessorVersion as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.deleteProcessorVersion as SinonStub + client.innerApiCalls.trainProcessorVersion as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes deleteProcessorVersion without error using callback', async () => { + it('invokes trainProcessorVersion without error using callback', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1261,27 +1403,27 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest() + new protos.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', - ['name'] + '.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', + ['parent'] ); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.deleteProcessorVersion = + client.innerApiCalls.trainProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { - client.deleteProcessorVersion( + client.trainProcessorVersion( request, ( err?: Error | null, result?: LROperation< - protos.google.protobuf.IEmpty, - protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionMetadata + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata > | null ) => { if (err) { @@ -1293,22 +1435,22 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); }); const operation = (await promise) as LROperation< - protos.google.protobuf.IEmpty, - protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionMetadata + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.ITrainProcessorVersionMetadata >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); const actualRequest = ( - client.innerApiCalls.deleteProcessorVersion as SinonStub + client.innerApiCalls.trainProcessorVersion as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.deleteProcessorVersion as SinonStub + client.innerApiCalls.trainProcessorVersion as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes deleteProcessorVersion with call error', async () => { + it('invokes trainProcessorVersion with call error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1318,34 +1460,34 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest() + new protos.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', - ['name'] + '.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', + ['parent'] ); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall( + client.innerApiCalls.trainProcessorVersion = stubLongRunningCall( undefined, expectedError ); await assert.rejects( - client.deleteProcessorVersion(request), + client.trainProcessorVersion(request), expectedError ); const actualRequest = ( - client.innerApiCalls.deleteProcessorVersion as SinonStub + client.innerApiCalls.trainProcessorVersion as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.deleteProcessorVersion as SinonStub + client.innerApiCalls.trainProcessorVersion as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes deleteProcessorVersion with LRO error', async () => { + it('invokes trainProcessorVersion with LRO error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1355,33 +1497,33 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest() + new protos.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', - ['name'] + '.google.cloud.documentai.v1beta3.TrainProcessorVersionRequest', + ['parent'] ); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); - client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall( + client.innerApiCalls.trainProcessorVersion = stubLongRunningCall( undefined, undefined, expectedError ); - const [operation] = await client.deleteProcessorVersion(request); + const [operation] = await client.trainProcessorVersion(request); await assert.rejects(operation.promise(), expectedError); const actualRequest = ( - client.innerApiCalls.deleteProcessorVersion as SinonStub + client.innerApiCalls.trainProcessorVersion as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.deleteProcessorVersion as SinonStub + client.innerApiCalls.trainProcessorVersion as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes checkDeleteProcessorVersionProgress without error', async () => { + it('invokes checkTrainProcessorVersionProgress without error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1398,7 +1540,7 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteProcessorVersionProgress( + const decodedOperation = await client.checkTrainProcessorVersionProgress( expectedResponse.name ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); @@ -1406,7 +1548,7 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - it('invokes checkDeleteProcessorVersionProgress with error', async () => { + it('invokes checkTrainProcessorVersionProgress with error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1422,15 +1564,15 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { expectedError ); await assert.rejects( - client.checkDeleteProcessorVersionProgress(''), + client.checkTrainProcessorVersionProgress(''), expectedError ); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); }); - describe('deployProcessorVersion', () => { - it('invokes deployProcessorVersion without error', async () => { + describe('deleteProcessorVersion', () => { + it('invokes deleteProcessorVersion without error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1440,10 +1582,10 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest() + new protos.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', + '.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name'] ); request.name = defaultValue1; @@ -1451,22 +1593,22 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.deployProcessorVersion = + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.deployProcessorVersion(request); + const [operation] = await client.deleteProcessorVersion(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); const actualRequest = ( - client.innerApiCalls.deployProcessorVersion as SinonStub + client.innerApiCalls.deleteProcessorVersion as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.deployProcessorVersion as SinonStub + client.innerApiCalls.deleteProcessorVersion as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes deployProcessorVersion without error using callback', async () => { + it('invokes deleteProcessorVersion without error using callback', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1476,10 +1618,10 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest() + new protos.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', + '.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name'] ); request.name = defaultValue1; @@ -1487,16 +1629,16 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.deployProcessorVersion = + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { - client.deployProcessorVersion( + client.deleteProcessorVersion( request, ( err?: Error | null, result?: LROperation< - protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionResponse, - protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionMetadata + protos.google.protobuf.IEmpty, + protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionMetadata > | null ) => { if (err) { @@ -1508,22 +1650,22 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); }); const operation = (await promise) as LROperation< - protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionResponse, - protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionMetadata + protos.google.protobuf.IEmpty, + protos.google.cloud.documentai.v1beta3.IDeleteProcessorVersionMetadata >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); const actualRequest = ( - client.innerApiCalls.deployProcessorVersion as SinonStub + client.innerApiCalls.deleteProcessorVersion as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.deployProcessorVersion as SinonStub + client.innerApiCalls.deleteProcessorVersion as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes deployProcessorVersion with call error', async () => { + it('invokes deleteProcessorVersion with call error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1533,34 +1675,34 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest() + new protos.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', + '.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name'] ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); - client.innerApiCalls.deployProcessorVersion = stubLongRunningCall( + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall( undefined, expectedError ); await assert.rejects( - client.deployProcessorVersion(request), + client.deleteProcessorVersion(request), expectedError ); const actualRequest = ( - client.innerApiCalls.deployProcessorVersion as SinonStub + client.innerApiCalls.deleteProcessorVersion as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.deployProcessorVersion as SinonStub + client.innerApiCalls.deleteProcessorVersion as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes deployProcessorVersion with LRO error', async () => { + it('invokes deleteProcessorVersion with LRO error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1570,33 +1712,33 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest() + new protos.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', + '.google.cloud.documentai.v1beta3.DeleteProcessorVersionRequest', ['name'] ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); - client.innerApiCalls.deployProcessorVersion = stubLongRunningCall( + client.innerApiCalls.deleteProcessorVersion = stubLongRunningCall( undefined, undefined, expectedError ); - const [operation] = await client.deployProcessorVersion(request); + const [operation] = await client.deleteProcessorVersion(request); await assert.rejects(operation.promise(), expectedError); const actualRequest = ( - client.innerApiCalls.deployProcessorVersion as SinonStub + client.innerApiCalls.deleteProcessorVersion as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.deployProcessorVersion as SinonStub + client.innerApiCalls.deleteProcessorVersion as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes checkDeployProcessorVersionProgress without error', async () => { + it('invokes checkDeleteProcessorVersionProgress without error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1613,7 +1755,7 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeployProcessorVersionProgress( + const decodedOperation = await client.checkDeleteProcessorVersionProgress( expectedResponse.name ); assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); @@ -1621,7 +1763,7 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - it('invokes checkDeployProcessorVersionProgress with error', async () => { + it('invokes checkDeleteProcessorVersionProgress with error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1637,15 +1779,15 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { expectedError ); await assert.rejects( - client.checkDeployProcessorVersionProgress(''), + client.checkDeleteProcessorVersionProgress(''), expectedError ); assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); }); - describe('undeployProcessorVersion', () => { - it('invokes undeployProcessorVersion without error', async () => { + describe('deployProcessorVersion', () => { + it('invokes deployProcessorVersion without error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -1655,10 +1797,225 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest() + new protos.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest', + '.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deployProcessorVersion = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deployProcessorVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deployProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.deployProcessorVersion = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deployProcessorVersion( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IDeployProcessorVersionMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deployProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deployProcessorVersion = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.deployProcessorVersion(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.deployProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deployProcessorVersion 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.DeployProcessorVersionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.DeployProcessorVersionRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deployProcessorVersion = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.deployProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deployProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeployProcessorVersionProgress 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.checkDeployProcessorVersionProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeployProcessorVersionProgress 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.checkDeployProcessorVersionProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('undeployProcessorVersion', () => { + it('invokes undeployProcessorVersion 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.UndeployProcessorVersionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.UndeployProcessorVersionRequest', ['name'] ); request.name = defaultValue1; @@ -2924,8 +3281,8 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { }); }); - describe('listProcessorTypes', () => { - it('invokes listProcessorTypes without error', async () => { + describe('evaluateProcessorVersion', () => { + it('invokes evaluateProcessorVersion without error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -2935,40 +3292,33 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorTypesRequest() + new protos.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', - ['parent'] + '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', + ['processorVersion'] ); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorType() - ), - generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorType() - ), - generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorType() - ), - ]; - client.innerApiCalls.listProcessorTypes = - stubSimpleCall(expectedResponse); - const [response] = await client.listProcessorTypes(request); + request.processorVersion = defaultValue1; + const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.evaluateProcessorVersion = + stubLongRunningCall(expectedResponse); + const [operation] = await client.evaluateProcessorVersion(request); + const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); const actualRequest = ( - client.innerApiCalls.listProcessorTypes as SinonStub + client.innerApiCalls.evaluateProcessorVersion as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.listProcessorTypes as SinonStub + client.innerApiCalls.evaluateProcessorVersion as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes listProcessorTypes without error using callback', async () => { + it('invokes evaluateProcessorVersion without error using callback', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -2978,21 +3328,244 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorTypesRequest() + new protos.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', - ['parent'] + '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', + ['processorVersion'] ); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorType() - ), - generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorType() - ), + request.processorVersion = defaultValue1; + const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.evaluateProcessorVersion = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.evaluateProcessorVersion( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionResponse, + protos.google.cloud.documentai.v1beta3.IEvaluateProcessorVersionMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.evaluateProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.evaluateProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes evaluateProcessorVersion 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.EvaluateProcessorVersionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', + ['processorVersion'] + ); + request.processorVersion = defaultValue1; + const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.evaluateProcessorVersion = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.evaluateProcessorVersion(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.evaluateProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.evaluateProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes evaluateProcessorVersion 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.EvaluateProcessorVersionRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.EvaluateProcessorVersionRequest', + ['processorVersion'] + ); + request.processorVersion = defaultValue1; + const expectedHeaderRequestParams = `processor_version=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.evaluateProcessorVersion = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.evaluateProcessorVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.evaluateProcessorVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.evaluateProcessorVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkEvaluateProcessorVersionProgress 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.checkEvaluateProcessorVersionProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkEvaluateProcessorVersionProgress 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.checkEvaluateProcessorVersionProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listProcessorTypes', () => { + it('invokes listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorType() + ), + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorType() + ), + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorType() + ), + ]; + client.innerApiCalls.listProcessorTypes = + stubSimpleCall(expectedResponse); + const [response] = await client.listProcessorTypes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProcessorTypes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProcessorTypes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorTypes 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.ListProcessorTypesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ListProcessorTypesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorType() + ), + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorType() + ), generateSampleMessage( new protos.google.cloud.documentai.v1beta3.ProcessorType() ), @@ -3463,12 +4036,375 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { const responses = await promise; assert.deepStrictEqual(responses, expectedResponse); assert( - (client.descriptors.page.listProcessors.createStream as SinonStub) + (client.descriptors.page.listProcessors.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProcessors, request) + ); + assert( + (client.descriptors.page.listProcessors.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ListProcessorsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProcessors.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ListProcessorsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ListProcessorsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('listProcessorVersions', () => { + it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ), + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ), + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ), + ]; + client.innerApiCalls.listProcessorVersions = + stubSimpleCall(expectedResponse); + const [response] = await client.listProcessorVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProcessorVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProcessorVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ), + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ), + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ), + ]; + client.innerApiCalls.listProcessorVersions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProcessorVersions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.documentai.v1beta3.IProcessorVersion[] + | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProcessorVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProcessorVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorVersions 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProcessorVersions = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.listProcessorVersions(request), + expectedError + ); + const actualRequest = ( + client.innerApiCalls.listProcessorVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProcessorVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProcessorVersionsStream 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.ListProcessorVersionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ), + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ), + generateSampleMessage( + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + ), + ]; + client.descriptors.page.listProcessorVersions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listProcessorVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.documentai.v1beta3.ProcessorVersion[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.documentai.v1beta3.ProcessorVersion + ) => { + 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.listProcessorVersions + .createStream as SinonStub + ) .getCall(0) - .calledWith(client.innerApiCalls.listProcessors, request) + .calledWith(client.innerApiCalls.listProcessorVersions, request) ); assert( - (client.descriptors.page.listProcessors.createStream as SinonStub) + ( + client.descriptors.page.listProcessorVersions + .createStream as SinonStub + ) .getCall(0) .args[2].otherArgs.headers['x-goog-request-params'].includes( expectedHeaderRequestParams @@ -3476,7 +4412,7 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); }); - it('invokes listProcessorsStream with error', async () => { + it('invokes listProcessorVersionsStream with error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -3486,24 +4422,26 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest() + new protos.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorsRequest', + '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent'] ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); - client.descriptors.page.listProcessors.createStream = + client.descriptors.page.listProcessorVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProcessorsStream(request); + const stream = client.listProcessorVersionsStream(request); const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.Processor[] = + const responses: protos.google.cloud.documentai.v1beta3.ProcessorVersion[] = []; stream.on( 'data', - (response: protos.google.cloud.documentai.v1beta3.Processor) => { + ( + response: protos.google.cloud.documentai.v1beta3.ProcessorVersion + ) => { responses.push(response); } ); @@ -3516,12 +4454,18 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { }); await assert.rejects(promise, expectedError); assert( - (client.descriptors.page.listProcessors.createStream as SinonStub) + ( + client.descriptors.page.listProcessorVersions + .createStream as SinonStub + ) .getCall(0) - .calledWith(client.innerApiCalls.listProcessors, request) + .calledWith(client.innerApiCalls.listProcessorVersions, request) ); assert( - (client.descriptors.page.listProcessors.createStream as SinonStub) + ( + client.descriptors.page.listProcessorVersions + .createStream as SinonStub + ) .getCall(0) .args[2].otherArgs.headers['x-goog-request-params'].includes( expectedHeaderRequestParams @@ -3529,7 +4473,7 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); }); - it('uses async iteration with listProcessors without error', async () => { + it('uses async iteration with listProcessorVersions without error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -3539,41 +4483,46 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest() + new protos.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorsRequest', + '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent'] ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.Processor() + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() ), generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.Processor() + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() ), generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.Processor() + new protos.google.cloud.documentai.v1beta3.ProcessorVersion() ), ]; - client.descriptors.page.listProcessors.asyncIterate = + client.descriptors.page.listProcessorVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.documentai.v1beta3.IProcessor[] = []; - const iterable = client.listProcessorsAsync(request); + const responses: protos.google.cloud.documentai.v1beta3.IProcessorVersion[] = + []; + const iterable = client.listProcessorVersionsAsync(request); for await (const resource of iterable) { responses.push(resource!); } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( ( - client.descriptors.page.listProcessors.asyncIterate as SinonStub + client.descriptors.page.listProcessorVersions + .asyncIterate as SinonStub ).getCall(0).args[1], request ); assert( - (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + ( + client.descriptors.page.listProcessorVersions + .asyncIterate as SinonStub + ) .getCall(0) .args[2].otherArgs.headers['x-goog-request-params'].includes( expectedHeaderRequestParams @@ -3581,7 +4530,7 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); }); - it('uses async iteration with listProcessors with error', async () => { + it('uses async iteration with listProcessorVersions with error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -3591,20 +4540,20 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorsRequest() + new protos.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorsRequest', + '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', ['parent'] ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); - client.descriptors.page.listProcessors.asyncIterate = + client.descriptors.page.listProcessorVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProcessorsAsync(request); + const iterable = client.listProcessorVersionsAsync(request); await assert.rejects(async () => { - const responses: protos.google.cloud.documentai.v1beta3.IProcessor[] = + const responses: protos.google.cloud.documentai.v1beta3.IProcessorVersion[] = []; for await (const resource of iterable) { responses.push(resource!); @@ -3612,12 +4561,16 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { }); assert.deepStrictEqual( ( - client.descriptors.page.listProcessors.asyncIterate as SinonStub + client.descriptors.page.listProcessorVersions + .asyncIterate as SinonStub ).getCall(0).args[1], request ); assert( - (client.descriptors.page.listProcessors.asyncIterate as SinonStub) + ( + client.descriptors.page.listProcessorVersions + .asyncIterate as SinonStub + ) .getCall(0) .args[2].otherArgs.headers['x-goog-request-params'].includes( expectedHeaderRequestParams @@ -3626,8 +4579,8 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { }); }); - describe('listProcessorVersions', () => { - it('invokes listProcessorVersions without error', async () => { + describe('listEvaluations', () => { + it('invokes listEvaluations without error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -3637,40 +4590,39 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest() + new protos.google.cloud.documentai.v1beta3.ListEvaluationsRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + '.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent'] ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), ]; - client.innerApiCalls.listProcessorVersions = - stubSimpleCall(expectedResponse); - const [response] = await client.listProcessorVersions(request); + client.innerApiCalls.listEvaluations = stubSimpleCall(expectedResponse); + const [response] = await client.listEvaluations(request); assert.deepStrictEqual(response, expectedResponse); const actualRequest = ( - client.innerApiCalls.listProcessorVersions as SinonStub + client.innerApiCalls.listEvaluations as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.listProcessorVersions as SinonStub + client.innerApiCalls.listEvaluations as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes listProcessorVersions without error using callback', async () => { + it('invokes listEvaluations without error using callback', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -3680,35 +4632,33 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest() + new protos.google.cloud.documentai.v1beta3.ListEvaluationsRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + '.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent'] ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), ]; - client.innerApiCalls.listProcessorVersions = + client.innerApiCalls.listEvaluations = stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { - client.listProcessorVersions( + client.listEvaluations( request, ( err?: Error | null, - result?: - | protos.google.cloud.documentai.v1beta3.IProcessorVersion[] - | null + result?: protos.google.cloud.documentai.v1beta3.IEvaluation[] | null ) => { if (err) { reject(err); @@ -3721,16 +4671,16 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { const response = await promise; assert.deepStrictEqual(response, expectedResponse); const actualRequest = ( - client.innerApiCalls.listProcessorVersions as SinonStub + client.innerApiCalls.listEvaluations as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.listProcessorVersions as SinonStub + client.innerApiCalls.listEvaluations as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes listProcessorVersions with error', async () => { + it('invokes listEvaluations with error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -3740,34 +4690,31 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest() + new protos.google.cloud.documentai.v1beta3.ListEvaluationsRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + '.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent'] ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); - client.innerApiCalls.listProcessorVersions = stubSimpleCall( + client.innerApiCalls.listEvaluations = stubSimpleCall( undefined, expectedError ); - await assert.rejects( - client.listProcessorVersions(request), - expectedError - ); + await assert.rejects(client.listEvaluations(request), expectedError); const actualRequest = ( - client.innerApiCalls.listProcessorVersions as SinonStub + client.innerApiCalls.listEvaluations as SinonStub ).getCall(0).args[0]; assert.deepStrictEqual(actualRequest, request); const actualHeaderRequestParams = ( - client.innerApiCalls.listProcessorVersions as SinonStub + client.innerApiCalls.listEvaluations as SinonStub ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - it('invokes listProcessorVersionsStream without error', async () => { + it('invokes listEvaluationsStream without error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -3777,36 +4724,34 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest() + new protos.google.cloud.documentai.v1beta3.ListEvaluationsRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + '.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent'] ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), ]; - client.descriptors.page.listProcessorVersions.createStream = + client.descriptors.page.listEvaluations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProcessorVersionsStream(request); + const stream = client.listEvaluationsStream(request); const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.ProcessorVersion[] = + const responses: protos.google.cloud.documentai.v1beta3.Evaluation[] = []; stream.on( 'data', - ( - response: protos.google.cloud.documentai.v1beta3.ProcessorVersion - ) => { + (response: protos.google.cloud.documentai.v1beta3.Evaluation) => { responses.push(response); } ); @@ -3820,18 +4765,12 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { const responses = await promise; assert.deepStrictEqual(responses, expectedResponse); assert( - ( - client.descriptors.page.listProcessorVersions - .createStream as SinonStub - ) + (client.descriptors.page.listEvaluations.createStream as SinonStub) .getCall(0) - .calledWith(client.innerApiCalls.listProcessorVersions, request) + .calledWith(client.innerApiCalls.listEvaluations, request) ); assert( - ( - client.descriptors.page.listProcessorVersions - .createStream as SinonStub - ) + (client.descriptors.page.listEvaluations.createStream as SinonStub) .getCall(0) .args[2].otherArgs.headers['x-goog-request-params'].includes( expectedHeaderRequestParams @@ -3839,7 +4778,7 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); }); - it('invokes listProcessorVersionsStream with error', async () => { + it('invokes listEvaluationsStream with error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -3849,26 +4788,24 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest() + new protos.google.cloud.documentai.v1beta3.ListEvaluationsRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + '.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent'] ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); - client.descriptors.page.listProcessorVersions.createStream = + client.descriptors.page.listEvaluations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProcessorVersionsStream(request); + const stream = client.listEvaluationsStream(request); const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.documentai.v1beta3.ProcessorVersion[] = + const responses: protos.google.cloud.documentai.v1beta3.Evaluation[] = []; stream.on( 'data', - ( - response: protos.google.cloud.documentai.v1beta3.ProcessorVersion - ) => { + (response: protos.google.cloud.documentai.v1beta3.Evaluation) => { responses.push(response); } ); @@ -3881,18 +4818,12 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { }); await assert.rejects(promise, expectedError); assert( - ( - client.descriptors.page.listProcessorVersions - .createStream as SinonStub - ) + (client.descriptors.page.listEvaluations.createStream as SinonStub) .getCall(0) - .calledWith(client.innerApiCalls.listProcessorVersions, request) + .calledWith(client.innerApiCalls.listEvaluations, request) ); assert( - ( - client.descriptors.page.listProcessorVersions - .createStream as SinonStub - ) + (client.descriptors.page.listEvaluations.createStream as SinonStub) .getCall(0) .args[2].otherArgs.headers['x-goog-request-params'].includes( expectedHeaderRequestParams @@ -3900,7 +4831,7 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); }); - it('uses async iteration with listProcessorVersions without error', async () => { + it('uses async iteration with listEvaluations without error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -3910,46 +4841,42 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest() + new protos.google.cloud.documentai.v1beta3.ListEvaluationsRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + '.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent'] ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ProcessorVersion() + new protos.google.cloud.documentai.v1beta3.Evaluation() ), ]; - client.descriptors.page.listProcessorVersions.asyncIterate = + client.descriptors.page.listEvaluations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.documentai.v1beta3.IProcessorVersion[] = + const responses: protos.google.cloud.documentai.v1beta3.IEvaluation[] = []; - const iterable = client.listProcessorVersionsAsync(request); + const iterable = client.listEvaluationsAsync(request); for await (const resource of iterable) { responses.push(resource!); } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( ( - client.descriptors.page.listProcessorVersions - .asyncIterate as SinonStub + client.descriptors.page.listEvaluations.asyncIterate as SinonStub ).getCall(0).args[1], request ); assert( - ( - client.descriptors.page.listProcessorVersions - .asyncIterate as SinonStub - ) + (client.descriptors.page.listEvaluations.asyncIterate as SinonStub) .getCall(0) .args[2].otherArgs.headers['x-goog-request-params'].includes( expectedHeaderRequestParams @@ -3957,7 +4884,7 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); }); - it('uses async iteration with listProcessorVersions with error', async () => { + it('uses async iteration with listEvaluations with error', async () => { const client = new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( { @@ -3967,20 +4894,20 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { ); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest() + new protos.google.cloud.documentai.v1beta3.ListEvaluationsRequest() ); const defaultValue1 = getTypeDefaultValue( - '.google.cloud.documentai.v1beta3.ListProcessorVersionsRequest', + '.google.cloud.documentai.v1beta3.ListEvaluationsRequest', ['parent'] ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); - client.descriptors.page.listProcessorVersions.asyncIterate = + client.descriptors.page.listEvaluations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProcessorVersionsAsync(request); + const iterable = client.listEvaluationsAsync(request); await assert.rejects(async () => { - const responses: protos.google.cloud.documentai.v1beta3.IProcessorVersion[] = + const responses: protos.google.cloud.documentai.v1beta3.IEvaluation[] = []; for await (const resource of iterable) { responses.push(resource!); @@ -3988,16 +4915,12 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { }); assert.deepStrictEqual( ( - client.descriptors.page.listProcessorVersions - .asyncIterate as SinonStub + client.descriptors.page.listEvaluations.asyncIterate as SinonStub ).getCall(0).args[1], request ); assert( - ( - client.descriptors.page.listProcessorVersions - .asyncIterate as SinonStub - ) + (client.descriptors.page.listEvaluations.asyncIterate as SinonStub) .getCall(0) .args[2].otherArgs.headers['x-goog-request-params'].includes( expectedHeaderRequestParams @@ -4558,6 +5481,97 @@ describe('v1beta3.DocumentProcessorServiceClient', () => { }); describe('Path templates', () => { + describe('evaluation', () => { + const fakePath = '/rendered/path/evaluation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + processor: 'processorValue', + processor_version: 'processorVersionValue', + evaluation: 'evaluationValue', + }; + const client = + new documentprocessorserviceModule.v1beta3.DocumentProcessorServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + client.pathTemplates.evaluationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.evaluationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('evaluationPath', () => { + const result = client.evaluationPath( + 'projectValue', + 'locationValue', + 'processorValue', + 'processorVersionValue', + 'evaluationValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.evaluationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromEvaluationName', () => { + const result = client.matchProjectFromEvaluationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.evaluationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromEvaluationName', () => { + const result = client.matchLocationFromEvaluationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.evaluationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProcessorFromEvaluationName', () => { + const result = client.matchProcessorFromEvaluationName(fakePath); + assert.strictEqual(result, 'processorValue'); + assert( + (client.pathTemplates.evaluationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchProcessorVersionFromEvaluationName', () => { + const result = client.matchProcessorVersionFromEvaluationName(fakePath); + assert.strictEqual(result, 'processorVersionValue'); + assert( + (client.pathTemplates.evaluationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchEvaluationFromEvaluationName', () => { + const result = client.matchEvaluationFromEvaluationName(fakePath); + assert.strictEqual(result, 'evaluationValue'); + assert( + (client.pathTemplates.evaluationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('humanReviewConfig', () => { const fakePath = '/rendered/path/humanReviewConfig'; const expectedParameters = { diff --git a/release-please-config.json b/release-please-config.json index 3790b02fa0d..c41931bd7f9 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -78,7 +78,6 @@ "packages/google-cloud-security-privateca": {}, "packages/google-cloud-secretmanager": {}, "packages/google-cloud-scheduler": {}, - "packages/google-cloud-secretmanager": {}, "packages/google-cloud-security-publicca": {}, "packages/google-cloud-servicedirectory": {}, "packages/google-cloud-shell": {},